This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How can I set Uart2 to exchange data?

void initialize_system (void)
{
// Initialize the serial port (9600, 8, N, 1)
PCON &= 0xBF; // Clear bit 7 of the PCON register (SMOD1 = 0)
SCON2 = 0x50; // 0101,0000 (Mode 1 and RxD enable)
TMOD |= 0x20; // Timer #1 in autoreload 8 bit mode
TCON = 0x40; // Set Timer #1 to run mode
TH1 = 0xFD; // Baud rate is determined by
// Timer #1 overflow rate
// Baud Rate = (Fcpu / 384) / (256 - TH1)
// Fcpu = 11.0592 MHz
// TH1 = 253
TR1 = 1; // Turn on Timer 1
TI2 = 1; // Set UART2 to send first char
}
void main (void)
{
unsigned char aaa;
initialize_system();

while(1)
{ aaa=_getkey();
printf("%c",aaa);
putchar(aaa);
}
}