??? 06/24/09 15:09 Read: times |
#166424 - Use printf to output to UART, but receive incorrect data Responding to: ???'s previous message |
Hi,
Because the MCU and the printer is DCE so I have to crossover connect the serial cable (Tx, Rx and GND by 3 wires). The MCU now can output to the printer. I use printf to output from MCU to PC to test first and find out that the value the PC receive is incorrect sometimes: e.g. Test1: Receive incorrect data Code: printf("Data 1:%un",1); //Output result to UART printf("Data 2:%un",1550); //Output result to UART printf("Data 3:%un",15550); //Output result to UART Output on PC HyperTerminal: Data 1: 511 Data 1: 1550 Data 1: 15550 Test2: Receive correct data Code: printf("Data 1:%un",1999); //Output result to UART printf("Data 2:%un",2999); //Output result to UART printf("Data 3:%un",3999); //Output result to UART Output on PC HyperTerminal: Data 1: 1999 Data 1: 2999 Data 1: 3999 Do you have any idea why the data receive is not correct sometimes? Please advice. Thanks guys. |