本帖最后由 ddddd6666 于 2013-1-19 09:40 编辑
#include<reg51.h>
#define uchar unsigned charuchar times,sec,min;
sbit LED=P1.0;
void t0_isr() interrupt 1
{ TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
times++;
if(times>=20)
{ times=0;
sec++;
if(sec>59)
{ sec=0;
min++; }
}
}
main()
{ TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
times=0;
sec=0;
min=0;
TR0=1;
ET0=1;
EA=1;
while(1)
{ if(min==20)TR0=0; LED=0; }
}
|