#include "reg52.h"
sfr AUXR = 0x8e;
unsigned char urdat;
void InitUart()
{
TMOD = 0x20;
TH1 = 0xfd;
TL1 = 0xfd;
TR1 = 1;
SCON = 0x50;
AUXR = 0x00;
ES = 1;
EA = 1;
}
void SendByte(unsigned char dat)//发送
{
SBUF = dat;
while(TI == 0);
TI = 0;
}
void ServiceUart() interrupt 4 //接收
{
if(RI == 1)
{
RI = 0;
urdat = SBUF;
SendByte(urdat + 1);
}
}
void main()
{
InitUart();
SendByte(0x5a);
SendByte(0xa5);
while(1);
}
标签:11,urdat,void,通信,unsigned,char,SendByte,串口 From: https://www.cnblogs.com/Unclesundada/p/17014076.html