#include<reg52.h>
unsigned char i=0;
unsigned char cnt=0;
unsigned int sec=0;
unsigned char smg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,};
unsigned char wx[]={0xfe,0xfd,0xfb,0xf7,};
void disp()
{
unsigned int i;
unsigned char smgbuff[]={smg[sec%10],smg[(sec/10)%10] ,smg[(sec/100)%10],smg[(sec/1000)],};
while(1)
{
P0=0XFF;
P1=wx[i];
P0=smgbuff[i];
i++;
if(i>=4)
{
i=0;
}
}
}
void main()
{
TMOD=0X01;
TH0=0XFC; //1ms
TL0=0X67;
TR0=1;
EA=1;
ET1=1;
while(1)
{
disp();
}
}
void zd() interrupt 1
{
TH0=0XFC;
TL0=0X67;
cnt++;
if(cnt>=1000)
{
cnt=0;
sec++;
}
}
|