关于PICC18的timer1中断编程
#include#include
unsigned char i=0;
void tmint(void)
{ IPEN=0;
INTCON=0x00;
INTCON2=0x00;
INTCON3=0x00;
PIE1=0x00;
PIE2=0x00;
TMR1IF=0;
T1CON=0xA0;
}
void interrupt clkint(void)
{ TMR1IE=0;
i++;
TMR1ON=0;
TMR1IF=0;
TMR1H=0x00;
TMR1L=0x00;
TMR1ON=1;
if(i%2==0)RD7=1;
else RD7=0;
TMR1IE=1;
}
void main(void)
{ TRISD=0x00;
LATD=0x00;
PORTD=0x00;
tmint();
TMR1H=0x00;
TMR1L=0x00;
TMR1ON=1;
GIE=1;
PEIE=1;
TMR1IE=1;
while(1)
{;
}
}
页:
[1]