Electronic – use only 4 wires of an 8 wire serial port with hardware flow control

flow controlserialuart

I'm looking to connect a Telit UE910 cellular module to a microcontroller. The module uses an 8 wire RS232 style serial connection for the main serial (USIF0). I'd rather not tie up 8 IO pins, but I would still like to use hardware flow control. Is it possible to only use 4 of the 8 wires (RX, TX, CTS, RTS)?

The module also supports using only 2 wires with software flow control. The datasheet states that you should tie RTS to ground when not using hardware flow control. I believe this is just to prevent RTS from floating, but it's possible it uses this to switch between HW and SW flow control mode. Is this likely?

Best Answer

You seem to have a major misconception what "serial" means. Serial means that bits of data are transmitted serially, meaning after each other in time. The number of bits you consider a word in a serial transmission scheme has nothing at all to do with the number of wires and therefore the number of microcontroller pins needed to connect to those wire.

There are various types of serial interfaces, but RS-232 uses a single signal for each direction. The most basic RS-232 interface for bi-directional communication uses only 3 wires: TX, RX, and GND. It is common to use a protocol that logically sends 8 bits at a time, but that has nothing to do with the number of wires since each of those bits are sent in series (hence the name "serial") over the same wire.

If you want to add "hardware flow control" to the basic RS-232 interface, then you need two more wires, RTS and CTS for the bi-directional case. Some microcontrollers come with fancy enough UARTs built in that they can handle RTS and CTS directly in the hardware. On others you have to implement this in the firmware, although that's not all that hard.

Software flow control is done with in-band signalling and uses only the basic two wires, RX and TX (plus GND, but that's implied so we don't normally say that). Usually this is done by sending XOFF to tell the other side to stop sending, then XON to say it's OK to send more stuff. If your data never contains these codes otherwise, then there is nothing more you have to do. Note that XON and XOFF are in the control codes space from 0 to 31, so would not be used if the protocol is text-based. If you are using a binary protocol where all of the codes 0-255 are possible, then you usually use a escape mechanism to add back the codes used by XON and XOFF.

Keep in mind that microcontrollers can't connect directly to RS-232. The convention is for logic-level UARTs, such as included in microcontrollers, to have the RS-232 data inverted on their pins and at the normal logical level. For example, 0 V at the UART would translate to over 5 V on the RS-232 wire, and logic high (like 3.3 or 5 V) at the UART would translate to under -5 V on the RS-232 wire.