定时器程序.docVIP

  • 77
  • 0
  • 约6.64千字
  • 约 24页
  • 2016-08-25 发布于河南
  • 举报
定时器程序

#includereg51.h #define uchar unsigned char #define uint unsigned int sbit LED=P0^0; uchar T_Count=0; void main() { TMOD=0x00; //定时器 0 工作方式 0 TH0=(8192-5000)/32; //5ms 定时 TL0=(8192-5000)%32; IE=0x82; //允许 T0 中断 TR0=1; while(1); } //T0 中断函数 void LED_Flash() interrupt 1 { TH0=(8192-5000)/32; //恢复初值 TL0=(8192-5000)%32; if(++T_Count==100) //0.5s 开关一次 LED { LED=~LED; T_Count=0; } } 28 TIMER0 控制流水灯 #includereg51.h #includeintrins.h #define uchar unsigned char #define uint unsigned int void main() { uchar T_Count=0; P0=0xfe; P2=0xfe; TMOD=0x01; //定时器 0 工作方式 1

文档评论(0)

1亿VIP精品文档

相关文档