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
P3.1 UART0-TXD to MAX232 T1IN to T1OUT to TXD on DB-9 P3.0 UART0-RXD to MAX232 R1OUT to R1IN to RXD on DB-9 DB-9 pin 5 to GND
are you using the correct cable, some connections need R and T crossed, some do not. If you use std DB9 pinning (BTW it is not a DB :), althought everyboddy and his brother calls it that) you need R and T crossed in the cable or T and T will connect.
Erik
I thought this might be it at first too, but the 4 port serial card takes care of the pin swapping.
Stephen; As Erik points out, you need to define your target board RS232 connections. I assume that you are building your target system and we are not talking of an eval board from some vendor. You need to decide if your system will be a DCE connection or a DTE connection. The PC is normally defined as a DCE and an eval board is defined as a DTE in which case the eval connections for Rx and Tx are reversed and you can use a straight through cable. If both ends are defined as DCE, then you will need a cable reversing pins Rx and TX called a 'Null Modem' connection. Google RS232 and you will get several hits on proper pin definitions. It sounds to me that you might want your target board defined as DCE so talking to a PC with something like Hyperterminal, you will need a Null Modem cable. Of course Hyperterminal doesn't care what connection you have. I was just using that as an example. But if you plan to connect to some accessory, it most likly will be a DTE and your target should be a DCE. Bradford
Stephen; I was out rambling with my typing and did not read your post about the four port card. Please disregard my post. Sorry about that. Bradford
My PC is DTE. Pin 3 on the DB9 is TXD. I verified this with my oscilloscope. I've got the uPSD3354D wire-wrapped and pin 2 on its DB9 is TXD. You definitely had me checking. It's been a while since I've worked with this board.
.. 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
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.