求STC12C5A60S2单片机的串口收发程序,无论收到什么,均原样发出去

2024-11-18 13:55:23
推荐回答(1个)
回答1:

#include
void uart() interrupt 4
{
unsigned char tmp;
if(RI)
{
RI=0;
tmp=SBUF
SBUF=tmp;
while(TI=0);
TI=0;
}
}
main()
{
TMOD=0x20;
TH0=TL0=0xfd;
TR2=1;
ES=1;
EA=1;
SCON=0x50;
while(1);
}