#include
#define uint unsigned int
#define uchar unsigned char
sbit lw=P3^1;
sbit ld=P3^0;
uchar duan[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar wei[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
uint hour=0,minute=0,second=0,t02ms=0;
void INT_init()
{
TMOD=0x20;
TH1=256-200;
TL1=256-200;
EA=1;
TR1=1;
ET1=1;
}
void delay(uint i)
{
while(i--);
}
/* ************************************************************************************ */
main()
{
char i;
INT_init();
while(1)
{
for(i=0;i<=7;i++)
{
P1=wei[i];
switch(i)
{
case 0:P2=duan[hour/10];break;
case 1:P2=duan[hour%10];break;
case 2:P2=0xbf;break;
case 3:P2=duan[minute/10];break;
case 4:P2=duan[minute%10];break;
case 5:P2=0xbf;break;
case 6:P2=duan[second/10];break;
case 7:P2=duan[second%10];break;
default:break;
}
delay(30);
}
}
}
/* ************************************************************************************ */
void timerl(void) interrupt 3
{
t02ms++;
if(t02ms==5000)
{
t02ms=0;
second++;
if(second==60)
{
second=0;
minute++;
if(minute==60)
{
minute=0;
hour++;
if(hour==24)
hour=0;
}
}
}
}
相关文章









