We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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); } }