单片机timer-创新互联

dragonchip 第五代芯片单片机timer

void Timer1Mode3Init()
{
 TH1 = 0xF8;                                       //(65536 - 2000) / 256; set 2ms interrupt
  TL1 = 0x30;                                     //(65536 - 2000) % 256;

创新互联从2013年开始,先为天桥等服务建站,天桥等地企业,进行企业商务咨询服务。为天桥企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

 ET1 = 1;                          //timer1 overflow interrupt
 TMOD |= 0x10 ;                               // timer1,mode 3
 TR1 = 1;                                          // timer 1 start
 }
//==================================================================================
//
// name : Timer1 Interrupt
//
// function :
// -
//
//==================================================================================

void timer1(void) interrupt 3  //Timer1 interrupt 3
{
   ET1 = 0;
   TH1 = 0xF8;                                       //(65536 - 2000) / 256; set 2ms interrupt
   TL1 = 0x30;                                       //(65536 - 2000) % 256;
   LEDCount++;
   ET1 = 1;
}

在中断里面没有重新设置装载TH1 TL1的值,在时间上进入的中断时间差33倍,为66ms,有点吓人。


网站标题:单片机timer-创新互联
转载来于:http://scyanting.com/article/cdgpoc.html