#include<at89x51.h>
#define uchar unsigned char
uchar code buff[ ] = {0xc0 ,0xf9 ,0xa4 ,0xb0 ,0x99 ,0x92 ,0x82 ,0xf8 ,0x80 ,0x90} ;
uchar numberl,number2,number3,display;
long number;
void main( void)
{
display =1;
TMOD = 0x01;
TH0=(65535- 50000)/256;
TL0=(65535- 50000)%256;
ET0=1;
EA=1;
TR0=1;
TMOD = TMOD|0x20;
TH1 = 0x73;
TL1 =0x73;
PCON =0;
TR1 =1;
SCON =0x00;
while(1 )
{
if(display==1)
{
numberl=number%10;
number2=(number/10)%10;
number3=number/100;
SBUF=buff[numberl];
while(
ti==0);
TI=0;
SBUF=(buff[number2]&0x7f);
while(TI==0);
TI=0;
SBUF=buff[number3];
while(TI==0);
TI=0;
display =0;
}
}
}
void time0_int(void) interrupt 1
{
static uchar time_nu=0;
TR0=0;
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
time_nu ++ ;
if(time_nu==20)
{
display=1;
time_nu=0;
number++;
if(number==1000)
number=0;
}
TR0=1;
}
-
一周热门 更多>