英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流
标题:
timer1中断的编程技术
[打印本页]
作者:
winnie
时间:
2009-4-15 11:47
标题:
timer1中断的编程技术
#include
systemio();
const char table[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
unsigned int i=0;
main()
{
systemio(); //I/O初始化
T1CON=0x30;
TMR1IE=1;
PEIE=1;
GIE=1;
TMR1L=0x00;
TMR1H=0x00;
TMR1ON=1;
while(1)
{;}
}
void interrupt tmr(void)
{
TMR1IF=0;
TMR1ON=0;
if (i>7)
{
i=0;
}
else
{
PORTD=table
;
i=i+1;
}
TMR1L=0x00;
TMR1H=0x00;
TMR1ON=1;
}
systemio()
{
TRISD=0x00;
PORTD=0x00;
}
欢迎光临 英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 (http://enroobbs.com/)
Powered by Discuz! X3.2