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); } }
to Jon, Thank u first. I use the ST Microcontroller uPSD3234A. I can use Uart0 to exchange data with PC. But I can't echange date with PC by Uart1. I think my code must have some bug. Please help me. Thank u.
I think _getkey(), printf() and putchar() in the library use first Uart in a standard 8051. If you to use 2nd Uart you must write a new _getkey() and a new putchar() in your application.
Eric, Thank you first for your suggestion. I have rewritten the putchar() and _getkey(). But it still had no response. I suspect the setting of my code. Thank you again.