#include <reg51.h>
unsigned char c;
void InitUART(void)
{
TMOD = 0x20;
SCON = 0x50;
TH1 = 0xFD;
TL1 = TH1;
PCON = 0x00;
EA = 1;
ES = 1;
TR1 = 1;
}
void SendOneByte(c)
{
c = P1^1;
SBUF = c;
while(!TI);
TI = 0;
}
void main(void)
{
InitUART();
}
void UARTInterrupt(void) interrupt 4
{
if(RI)
{
RI = 0;
SendOneByte(c);
}
else
TI = 0;
} |