#include
#define th0 0x3c
#define tl0 0xb0 //50ms at 12MHz Fosc
#define T1sAt50msCount 20 //1s计数值
sbit WaveOut1=P2^0; //定义 方波1输出 端口
void Timer0() interrupt 1 //定时器T0 中断 函数
{
static uchar t50ms=0;
TL0=tl0;
TH0=th0;
if(++t50ms>=T1sAt50msCount)
{
t50ms-=T1sAt50msCount;
WaveOut1=~WaveOut1; //方波1输出 端口 电平翻转
}
}
void TimerInit() //定时器初始化 函数
{
TMOD=0x01; //T0 16位定时器
EA=1; //允许系统中断
ET0=1; //允许T0中断
TH0=th0;
TL0=tl0; //50ms 初值
TR0=1; //T0开始计时
}
void main() //主函数
{
TimerInit(); //调用 定时器初始化 函数
while(1); //循环系统
}
直接打字的,未编译
我宁愿欺骗不会高到我宁愿欺骗不会高到