#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
#define zxmaddr P0
#define zwmaddr P2
unsigned char flag,a,i;
uchar code table[]="The date is";/*共阴极数码管字形码,共阳极数码管取反即可*/
uchar code zixing[]={ 0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7c,0x39,0x5E,0x79,0x71};/*共阴极数码管字形码,共阳极数码管取反即可*/
uchar code ziwei[]={ 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
void init()
{
TMOD=0x20;
TH1=0xfd;
TL1=0xfd;
TR1=1;
REN=1;
SM0=0;
SM1=1;
EA=1;
ES=1;
}
void disp(void)
{
zwmaddr=~ziwei[7];
zxmaddr=~zixing[a&0x0f];
}
void send_char(unsigned char txd)
{
SBUF=txd;
while(!TI);
TI=0;
}
void main()
{
init();
while(1)
{
disp();
if(flag==1)
{
ES=0;
send_char(a);
ES=1;
flag=0;
}
}
}
void ser() interrupt 4
{
RI=0;
a=SBUF;
flag=1;
}
这个程序对这个图为什么不行呢?求指教
|