平安夜快乐。请教:我的89C51为何不返回发送值?我以用PC的两个RS232测试过,两个PC串口和测试软件是OK的,我的C51如下,请高手赐教。
#include <at89x51.h>
sbit P00=P0^0;
sbit P20=P2^0;
main()
{unsigned char i;
//unsigned long j;
SCON = 0x50; //SCON: serail mode 1, 8-bit UART, enable ucvr
TMOD = 0x20; //TMOD: timer 1, mode 2, 8-bit reload
PCON = 0x00; //SMOD=0;
TH1 = 0xFD; //Baud:9600 fosc=11.0592MHz
TL1 = 0xFD;
IE = 0x90; //Enable Serial Interrupt
TR1 = 1; // timer 1 run
P00=0;//only for display.
P20=0;
while(1)
{while(RI==0);
i=SBUF;
SBUF=i;
while(TI==0);
TI=0;
}
}