|
#include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
sbit cs=P1^0;
sbit wr=P1^2;
sbit rd=P1^1;
sbit intr=P1^3;
sbit seg1=P0^0;
sbit seg2=P0^1;
sbit seg3=P0^2;
void delayms(uint ms)
{
uint i,j;
for(i=ms;i>0;i--)
for(j=110;j>0;j--);
}
void write()
{
cs=0;
_nop_();
wr=0;
_nop_();
wr=1;
}
void read()
{
rd=0;
_nop_();
}
void mian()
{
uint result;
uint a1,a2,a3;
seg1=1;seg2=1;seg3=1;
P2=table[0];
delayms(5);
while(1)
{
write();
while(intr==0);
read();
result=P3;
a1=result/100;
a2=result%100/10;
a3=result%10;
seg1=1;seg2=0;seg3=0;
P2=table[a1];
delayms(5);
seg1=0;seg2=1;seg3=0;
P2=table[a2];
delayms(5);
seg1=0;seg2=0;seg3=1;
P2=table[a3];
delayms(5);
}
}
|
|