#include <reg51.h>
#define uchar unsigned char
uchar code Table[]= {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar num3,num4,ge1,shi1,num1,num2,ge,shi,num5,num6,ge2,shi2;
void delay()
{
uchar i,j;
for(i=40;i>0;i--)
for(j=110;j>0;j--);
}
void T0_time() interrupt 1
{
TH0=(65535-45872)/256;
TL0=(65535-45872)%256;
num1++;
num3++;
num5++;
if(num1==20)
{
num1=0;
num2--;
if(num2==0)
num2=45;
}
if(num3==20)
{
num3=0;
num4--;
if(num4==0)
num4=65;
}
if(num5==20)
{
num5=0;
num6--;
if(num6==0)
num6=76;
}
}
void display(uchar ge,uchar shi )
{
shi=num2/10;
ge=num2%10;
P2=0xfd;
P0=Table[ge]; delay();
P2=0xfe;
P0=Table[shi]; delay();
}
void display1(uchar ge1,uchar shi1)
{
shi1=num4/10;
ge1=num4%10;
P2=0xf7;
P0=Table[ge1]; delay();
P2=0xfb;
P0=Table[shi1]; delay();
}
void display2(uchar ge2,uchar shi2)
{
shi2=num6/10;
ge2=num6%10;
P2=0xdf;
P0=Table[ge2]; delay();
P2=0xef;
P0=Table[shi2]; delay();
}
void main()
{
TMOD=0x01;
TH0=(65535-45872)/256;
TL0=(65535-45872)%256;
EA=1;
ET0=1;
TR0=1;
num1=0;num2=45;
num3=0; num4=65;
num5=0;num6=76;
while(1)
{
display(ge,shi);
display1(ge1,shi1);
display2(ge2,shi2);
}
}
|