问题遇到的现象和发生背景 双机通信 方式3 带奇偶检验 9600的波特率 甲机查询发送代码 发送内容为缓冲区sbuff【10】
问题相关代码,请勿粘贴截图
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果
#include <reg51.h>
void UartSendByte(unsigned char c);
void UartInit(void);
//晶振频率
#define OSC_FREQ 11059200
#define BPS 9600
char sbuff[11];
void main(void)
{
UartInit();
while(1)
{
UartSendByte(sbuff[10]);//发送需要的数据。
}
}
void UartInit(void)
{
SCON = 0xD0;
TMOD = 0x20;
TH1 = TL1 =256 - OSC_FREQ/12/2/16/BPS;
TR1 = 1;
}
void UartSendByte(unsigned char c)
{
ACC = c;
TB8 = P;//校验位
SBUF = c;
while(!TI);
TI = 0;
}