#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
unsigned char Tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char x;
sbit P34=P3^4;
void delaylms(uint i)
{
uchar j;
while(i--)
for(j=0;j<115;j++);
}
void Display(unsigned int x)
{
P2=0x20;
P0=Tab[x/100];
delaylms(1);
P2=0x40;
P0=Tab[x%100/10];
delaylms(1);
P2=0x80;
P0=Tab[x%10];
delaylms(1);
}
void main(void)
{
TMOD=0x06;
EA=1;
ET0=1;
EX0=1;
IT0=1;
TH0=TL0=256-1;
TR0=1;
while(1)
Display(x);
}
void Time0(void) interrupt 1
{
x=0;
}
void Time1(void) interrupt 2
{
x=(x+1)%1000;
if(x==50)
x=0;
}
|