在这个代码中,我想用串口助手来控制数码管的显示,但是我并不想让显示的程序放在 interrupt 4 中(也就是说想在主函数中来控制数码管的该变)
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit du=P2^6;
sbit we=P2^7;
uchar a;
char code table []={0x3f,0x06,0x5b,0x4f,0x66,0x6d, 0x7d,0x07,0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71};
void main()
{
SCON=0X50;
PCON=0x00;
TMOD=0X20;
EA=1;
ES=1;
TL1=0Xfd;
TH1=0Xfd;
TR1=1;
du=0;
we=0;
while(1) ;
/* {
we=1;
P0=0x00;
we=0;
P0=0x00;
du=1;
P0=table[a];
du=0;
} */
}
void zhongduan() interrupt 4
{
ES=0;
RI=0;
a=SBUF;
we=1;
P0=0x00;
we=0;
P0=0xff;
du=1;
P0=table[a];
du=0;
EA=1;
}
此帖出自
小平头技术问答
一周热门 更多>