关于俩个单片机发送问题的程序
#include<reg51.h>
#define uchar unsigned char
char code map[]={0x3f,0x06,0x5b,0x4f,0x66,0x7d,0x07,0x7f,0x6f};
void delay(unsigned int time)
{
unsigned int j=0;
for(;time>0;time--)
for(j=0;j<125;j++);
}
void main(){
uchar counter=0;
TMOD=0x20;
TH1=TL1=0xf4;
PCON=0;
SCON=0x50;
TI=1;
while(1)
{SBUF=counter;
while(TI==0);
TI=0;
while(RI==0);
RI=0;
if(SBUF==counter)
{P2=map[counter];
if(++counter>9)counter=0;
delay(500);
}
}
}这是第一个单片机的
下面第二个的
#include<reg51.h>
#define uchar unsigned char
char code map[]={0x3f,0x06,0x5b,0x4f,0x66,0x7d,0x07,0x7f,0x6f};
void main()
{
uchar receive;
TMOD=0x20;
TH1=TL1=0xf4;
PCON=0;
SCON=0x50;
TR1=1;
while(1){
while(RI==1){
RI=0;
receive=SBUF;
SBUF=receive;
while(TI==0);
TI=0;
P2=map[receive];
}
}
}为什么显示的是图上的东西 不会自己跳转
|