#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit dula=P2^6;
sbit wela=P2^7;
sbit wr=P3^6;
sbit rd=P3^7;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uchar aa,bai,ge,shi,d,a;
void display(uchar bai,uchar shi,uchar ge);
void init()
{
TMOD=0x01;
TH0=0x80;
TL0=0xFE;
EA=1;
ET0=1;
TR0=1;
aa=0;
}
void start()
{
wr=1;
_nop_();
wr=0;
_nop_();
wr=1;
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=10;y>0;y--);
}
void main()
{
init();
while(1)
{
start();
rd=1;
_nop_();
rd=0;
_nop_();
d=P1;
rd=1;
bai=d/100;
shi=d%100/10;
ge=d%10;
for(a=10;a>0;a--)
{
display(bai,ge,shi);
}
}
}
void display(uchar bai,uchar shi,uchar ge)
{
dula=1;
P0=table[bai];
dula=0;
P0=0xff;
wela=1;
P0=0x7e;
wela=0;
delay(1);
dula=1;
P0=table[shi];
dula=0;
P0=0xff;
wela=1;
P0=0x7d;
wela=0;
delay(1);
dula=1;
P0=table[ge];
dula=0;
P0=0xff;
wela=1;
P0=0x7b;
wela=0;
delay(1);
}
void timer0() interrupt 1
{
TH0=0x80;
TL0=0xFE;
aa++;
}
|