英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流
标题:
关于PICC18的timer1中断编程
[打印本页]
作者:
winnie
时间:
2009-4-15 11:43
标题:
关于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)
{;
}
}
欢迎光临 英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 (http://enroobbs.com/)
Powered by Discuz! X3.2