单片机c语言用串口调试助手发送单片机接后发回来不相同 发11 12 13 14 15 16 17接ff 11 12 13 14 15 16
#include<reg52.h>#define uchar unsigned char
#define uint unsigned int
//sbit ledhong=P1^3;
//sbit rxd=P3^0;
//sbit ledlv=P1^2;
sbit led=P1^3;//1为灯指示灯亮0为灭
uchar aa=0;
uchar bb[7];
/*void delays()//1.3s
{
uint c;
for(c=0;c<32800;c++);
}*/
void main()
{
uchar cc=0;
EA=1;
ES=1;
REN=1;
TI=0;
RI=0;
SM0=0;
SM1=1;
PCON=0x00;
TMOD=0x20;
TH1=0xe8;
TL1=0xe8;
TR1=1;
while(1)
{
if(aa>6)
{
if(cc<7)
{
SBUF=bb[cc];
while(!TI);
TI=0;
cc++;
led=0;
}
}
}
}
void ser() interrupt 4
{
/*if(TI==1)
{
TI=0;
}*/
if(RI==1)
{
RI=0;
if(aa<7)
{bb[aa]=SBUF;}
aa++;
}
}