单片机编程 设单片机的晶振频率为12MHZ,请编出利用定时/计数器T0,使之工作在方式1,产生50ms定时,

日期:2012-04-15 21:54:26 人气:1

单片机编程 设单片机的晶振频率为12MHZ,请编出利用定时/计数器T0,使之工作在方式1,产生50ms定时,

#include"reg52.h" #define uchar unsigned char sbit Wave=P1^0; void Timer0() interrupt 1 { static uchar t50ms; TL0=0xb0; TH0=0x3c; t50ms=++t50ms%20; if(!t50ms) Wave=~Wave; } void TimerInit() { TMOD=0x01; TH0=0x3c; TL0=0xb0; TR0=1; EA=1; ET0=1; }
    A+
热门评论