利用串口控制数码管的静态显示,这么写可以吗?错在哪?
时间:10-02
整理:3721RD
点击:
#include<reg52.h>
unsigned char dat;
sbit duan=P2^0;
sbit wei=P2^1;
display(dat);
init()
{ SP=0x60;
SCON=0x50;
TMOD=0x20;
PCON=0x80;
TH1=0xe6;
TL1=0xe6;
TR1=1;
EA=1;
ES=1;
}
unsigned char code distable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d};
unsigned char code xtab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf};
void main()
{
init();
while(1)
{
;
}
}
void chuan() interrupt 4 using 0
{
RI=0;
dat=SBUF;
display(dat);
SBUF=dat;
while(TI==0);
TI=0;
}
display(dat)
{
wei=1;
P0=xtab[dat];
wei=0;
duan=1;
P0=distable[dat];
duan=0;
}
unsigned char dat;
sbit duan=P2^0;
sbit wei=P2^1;
display(dat);
init()
{ SP=0x60;
SCON=0x50;
TMOD=0x20;
PCON=0x80;
TH1=0xe6;
TL1=0xe6;
TR1=1;
EA=1;
ES=1;
}
unsigned char code distable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d};
unsigned char code xtab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf};
void main()
{
init();
while(1)
{
;
}
}
void chuan() interrupt 4 using 0
{
RI=0;
dat=SBUF;
display(dat);
SBUF=dat;
while(TI==0);
TI=0;
}
display(dat)
{
wei=1;
P0=xtab[dat];
wei=0;
duan=1;
P0=distable[dat];
duan=0;
}
在线等啊!谢谢了!
怎么没人啊!帮帮忙啊!
