1
\$\begingroup\$

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?

\$\endgroup\$
3
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ It may be worth mentioning that devices connecting to general RS232 devices have to be able to withstand indefinite short circuit to ground or to any voltage level up to ±25 volts. \$\endgroup\$ – RedGrittyBrick Sep 6 '13 at 14:26
  • \$\begingroup\$ By RS232 style serial I meant that it has the RING, DSR, DCD, and DTR lines. I suppose I should have said 8 wire instead of 8 bits. It's fine to ignore these? My microcontroller supports CTS and DTS and I'm aware of the inverted/logic level differences. \$\endgroup\$ – Eric Zillinger Sep 6 '13 at 14:45
  • 1
    \$\begingroup\$ @BigJ: Read the datasheet of the device you are trying to communicate with. With some devices you can safely ignore these seldom-used lines. With others certain pairs may need to be looped back on each other for the device to function. \$\endgroup\$ – Olin Lathrop Sep 6 '13 at 16:15
  • \$\begingroup\$ Nicely explained. Most modern motherboards can handle TTL on the serial port just fine, but you need to remember to invert the TX and RX on the microcontroller side. Of course, this wouldn't really be RS232 compatible, but it does often work in a pinch. \$\endgroup\$ – Scott Seidman Sep 6 '13 at 17:54
  • \$\begingroup\$ @OlinLathrop the datasheet makes no mention of 4 wire serial, which is why I'm asking this question. It does however allow 2 wire: "For a minimum implementation, only the TXD, RXD lines can be connected, the other lines can be left open provided a software flow control is implemented.". \$\endgroup\$ – Eric Zillinger Sep 6 '13 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.