winnie 发表于 2009-3-31 14:32:08

Timer1的定时中断程序

#include<pic.h>
volatile unsigned char counter;
void interrupt timer1(void)
{
   if(TMR1IE&&TMR1IF==1)
    {
    TMR1IF=0;
    counter ++;
    if(counter==0x08)
    {
    counter=0;
    RC0=0;
    TMR1IE=0;
    }
      TMR1H=0x3C;
      TMR1L=0xb0;
   
    }
}
void main()
{

   TRISC0=0;
   TRISC1=0;
   counter=0;
   RC0=1;
   RC1=0;
   TMR1CS=0;
   TMR1H=0x3c;
   TMR1L=0xb0;
   TMR1IF=0;
   TMR1IE=1;
   TMR1ON=1;
   INTCON=0XC0;//
   while(1)
    {
    RC0=0;
    if(TMR1IE==0) break;
    }
    while(1)
    {;}
   }
页: [1]
查看完整版本: Timer1的定时中断程序