#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar seg[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar number[4],a;
uint num=4500,cen;
void time()
{
TMOD=0x01;
TH0=0xfc;
TL0=0x67;
EA=1;
ET0=1;
TR0=1;
}
void main()
{
time();
while(1)
{
if(cen>1000)
{
cen=0;
number[0]=seg[num%10];
number[1]=seg[num/10%10];
number[2]=seg[num/100%10];
number[3]=seg[num/1000%10];
num--;
if(num==4480)
{
number[0]=seg[4480%10];
number[1]=seg[4480/10%10];
number[2]=seg[4480/100%10];
number[3]=seg[4480/1000%10];
while(1);
}
}
}
}
void timer() interrupt 1
{
uchar i;
TH0=0XFC;
TL0=0X67;
cen++;
switch(i)
{
case 0:P1=0x01;i++;P0=number[0];break;
case 1:P1=0x02;i++;P0=number[1];break;
case 2:P1=0x04;i++;P0=number[2];break;
case 3:P1=0x08;i=0;P0=number[3];break;
}
}
|