|
#include<reg51.h>
unsigned char code c[]={0xc0,0xf9,0xA4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char code cd[]={0x90,0x80,0xf8,0x82,0x92,0x99,0xb0,0xA4,0xf9,0xc0};
unsigned char second;
unsigned char tcount;
void main()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
ET0=1;
EA=1;
TR0=1;
tcount=0;
second=0;
P0=c[second/10];//0
P2=c[second%10];//0
while(1)//50ms
{
if(TF0==1) //开启查询
{
tcount++;
if(tcount==20)//1s
{
tcount=0;
second++;//1
if(second==60)
{
second=0;
}
P0=c[second/10];
P2=c[second%10];
}
TF0=0; //手动置0
TH0=(65336-50000)/256;
TL0=(65336-50000)%256;
}
}
}
void t0(void) interrupt 1 using 0
{
}
|
|