#include<reg52.h>
#define uchar unsigned char
uchar counter=0,tmp,second=0,minute=0, changed = 1;
main()
{
TMOD=0X01;
TH0=0xDc;
TL0=0x00;
EA=1;
ET0=1;
TR0=1;
while(1)
{
char a[10] = {0xc0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90};
tmp=counter%4;
switch(tmp)
{
case 0:{
P2 = 0x7f;
P0 = a[second%10];
}
break;
case 1:{
P2 = 0xbf;
P0 = a[second/10];
}
break;
case 2: {
P2 = 0xdf;
P0 = a[minute%10];
}
break;
case 3: {
P2 = 0xef;
P0 = a[minute/10];
}
break;
}
}
}
void zhongduan()interrupt 1
{
TH0=0xee;
TL0=0x00;
TF0=0;
TR0=1;
counter++;
if(counter==200)
{
counter=0;
second++;
if(second==60)
{
second=0;
minute++;
}
}
}
#include<reg52.h>
#define uc unsigned char
sbit beep=P2^0;
void timeint0()
{
TMOD=0X01;
TH0=0XFC;
TL0=0X18;
TR0=1;
ET0=1;
EA=1;
}
void time0int () interrupt 1
{
static int i=0;
TH0=0XFC;
TL0=0X18;
i++;
if(i==1000)
{
i=0;
beep=~beep;
}
}
void main()
{
timeint0();
while(1);
}