#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit JDQ=P2^0;
uchar Cnt50ms=0,Cnt1s=0,Cnt1min=0;//50毫秒、秒、分时间变量
//uchar num;
void main()
{
TMOD=0x01;
// TL0 = 0xB0;//50毫秒@12.000MHz
// TH0 = 0x3C;
TH0 = 0x4C;//50毫秒@11.0592MHz
TL0 = 0x00;
EA=1;
ET0=1;
TR0=1;
while(1)
{
if(Cnt1min==1)
{
Cnt1min=0;
JDQ=~JDQ;
}
}
}
void T0_time() interrupt 1
{
TH0 = 0x4C;
TL0 = 0x00;
Cnt50ms++;
if(Cnt50ms==20)
{
Cnt50ms=0;
Cnt1s++;
if(Cnt1s==60)
{
Cnt1s=0;
Cnt1min=1;
}
}
} |