#include
#define uint unsigned int
#define uchar unsigned char
sbit p20=P2^0;//数码管位选端界说
sbit p21=P2^1;//数码管位选端界说
sbit p22=P2^2;//数码管位选端界说
sbit cs=P2^4;
sbit rd=P2^5;
sbit wr=P2^6;
unsigned char code tab[] =
{
0XC0,//;0
0XF9,//;1
0XA4,//;2
0XB0,//;3
0X99,//;4
0X92,//;5
0X82,//;6
0XF8,//;7
0X80,//;8
0X90,//;9
};
void delay(uchar z)
{
uint i;
while(z–)
for (i=0;i<120;i++);
}
void disp(uchar a,uchar b,uchar c)
{
p20=1;
p21=0;
p22=0;
P0=tab[a];
delay(5);
P0=0xff;
p20=0;
p21=1;
p22=0;
P0=tab[b];
delay(5);
P0=0xff;
p20=0;
p21=0;
p22=1;
P0=tab[c];
delay(5);
P0=0xff;
}
void stdc()
{
cs=0;
wr=1;
wr=0;
wr=1;
}
void main()
{
uchar A,B,C,d;
while(1)
{
stdc();
delay(10);
rd=1;
delay(1);
rd=0;
d=P3;
rd=1;
A=d/100;
B=d%100/10;
C=d%10;
disp(A,B,C);
}
}