Electronic – UART connection

raspberry piuart

I want to implement an UART port, just like the raspberry, but I have seen other connections that include more pins (like the picture below)

DB9 connector pinout

In some cases, only TXD, RXD, CTS, RTS, GND are connected, in others all pins. I have googled a while and found this picture of RaspberryPi (figure below), and I was wondering what the difference is. If in the connection with the 9 pins connected I disconnect all but RXD, TXD and GND, will it work?

Mini-UART connector pinout

PD: I know the connector is not the same, I'm referring only to the signals.

Best Answer

The minimal pins required are TX, RX and GND. You mention adding a UART port, so I am going to center this discussion on the signals going into and out of a UART.

TxD (Transmitted Data, output) is transmitting characters from the UART to another device (e.g. a PC)
RxD (Received Data, input) is receiving characters from another device (e.g. a PC) into the UART
GND is the common ground reference

These TxD/RxD leads are "cross-connected" to the corresponding leads on the PC, e.g. TxD-RxD, and RxD-TxD.

There are then two pairs of handshaking leads: RTS/CTS and DTR/DSR. The first pair are on a per character basis for hardware flow control, and the last two are on a session basis.

RTS (Request To Send, output) is asserted to mean the UART is ready to send data
CTS (Clear To Send, input) is asserted to mean the far end dewvice (e.g. PC) is ready to receive data

These leads are "cross-connected" to the corresponding leads on the PC, e.g. RTS-CTS, and CTS-RTS.

DTR (Data Terminal Ready, output) is asserted to mean the UART is ready.
DSR (Data Set Ready, input) is asserted to mean the far end device (e.g. PC) is ready.

These leads are "cross-connected" to the corresponding leads on the PC, e.g. DTR-DSR, and DSR-DTR.

These four really only need to be brought out if you know you have a need for them. Hardware flow control is occasionally used by some applications, but can usually be turned off. The DTR lead will sometimes be used as an enable lead. The terminal program RealTerm can use either RTS/CTS or DTR/DSR for handshaking, and allows either the RTS or DTR leads to be manually set from its GUI.

I sometimes use this capability to allow me to set or reset up to two signals (corresponding to RTS and DTR) in a circuit. For example, you could run the DTR lead into an open-drain buffer connected to a microcontroller's \$\mathsf{\small \overline{\text{RESET}}} \$ line, and then you can reset the micro anytime by toggling the DTR lead from the PC.

There are then two remaining UART lines, which are mostly left over from the dial-up modem days and are seldom used anymore, so they can be ignored:

DCD (Data Carrier Detect) is asserted if a carrier is detected on the phone line
RI (Ring Indicator) is asserted if the phone line is ringing

IN the case of UARTs, all of these signals will be at the logic level of the system, usually 3.3v or 5v. The "idle", or "spacing" level for all of these signals is the high logic level (1), while the "asserted" level is ground (0).

To interface to the outside world, a level converter is needed to either convert the signals to RS-232 levels (+- 3v to +- 15v) to connect to a hardware COM port, or to a USB bridge which will appear as a virtual COM port on the PC. An idle, high logic level (1) corresponds to a negative RS-232 level (e.g. -5v), and an asserted, low logic level (0) corresponds to a positive RS-232 level (e.g. +5v).

The RS-232 level converter I linked to just handles TX/RX and GND; the USB bridge handles the handshaking leads as well.