关于串口通信
时间:10-02
整理:3721RD
点击:
先上程序
#include<reg52.h>
typedef unsigned char u8;
typedef unsigned int u16;
void UsartInit()
{
TMOD=0x20;
TH1=0xF3;
TL1=0xF3;
TR1=1;
EA=1;
ES=1;
SCON=0x50;
}
void main()
{
UsartInit();
while(1);
}
void Usart() interrupt 4
{
u8 receiveData;
receiveData=SBUF;
RI=0;
SBUF=receiveData;
TI=0;
}

如图所示发送1 ,接收9,发送和接收不一致,请问为什么,希望大神解答下,谢谢,波特率是4800应该没错
#include<reg52.h>
typedef unsigned char u8;
typedef unsigned int u16;
void UsartInit()
{
TMOD=0x20;
TH1=0xF3;
TL1=0xF3;
TR1=1;
EA=1;
ES=1;
SCON=0x50;
}
void main()
{
UsartInit();
while(1);
}
void Usart() interrupt 4
{
u8 receiveData;
receiveData=SBUF;
RI=0;
SBUF=receiveData;
TI=0;
}

如图所示发送1 ,接收9,发送和接收不一致,请问为什么,希望大神解答下,谢谢,波特率是4800应该没错
void Usart() interrupt 4
{
u8 receiveData;
receiveData=SBUF;
RI = 0;
SBUF=receiveData;
while(!TI);
TI=0;
}
仍然是显示9,
波特率 数据位 校验位 停止位都对 但还是错的话 上示波器直接看收发到底是什么
没有示波器
