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.
I cannot seem to get anything out of UART0 or 1 using printf(). What is the correct way to program these UARTS?
Thank you, Stephen Blair
.. I can't say with certainty re printf.
BUT I rcall that printf uses putchar (which i don't use either) and tend to recall that there is something you need to do to "install" or "activate" it.
also, are you sure that TH1 = -11, TL1 =0 is correct verify using the Kiel budrate generator http://www.keil.com/c51/baudrate.asp
Erik
19.2 is impossible using T1, you need another xtal or use T2
I'm using Timer2 to get the 19,200 baud. I tried adding the line:
TI = 1;
before:
printf("Testing");
In the Keil simulator, I got "Testing" in the UART #1 debug window. On the actual board I keep getting a never ending stream of spaces.
The simulator will not have to decode the output from the simulated UART.
When testing serial communication on real hardware, you should always verify the baudrate with an oscilloscope. That will catch rounding or spelling errors that may result in incorrect baudrates. Even when the PC is able to receive data, the baudrate should be checked - only with a perfect baudrate will the receiver have maximum probability of correctly receiving the data in a noisy environment.
Anyway - if the PC only shows spaces, the scope should tell what is actually sent on the serial cable.