7
\$\begingroup\$

The standard 9 pins RS232 connector has 9 pins. Those are:

1 -- DCD -- Data Carrier Detected
2 -- RxD -- Receive Data
3 -- TxD -- Transmit Data
4 -- DTR -- Data Terminal Ready
5 -- GND -- Signal Ground
6 -- DSR -- Data Set Ready
7 -- RTS -- Request to Send Data
8 -- CTS -- Clear to Send Data
9 -- RI -- Ring Indicator

  1. If I need bi-directional communication it is obvious that I should connect RxD and TxD. What should I do with other signals/pins - connect to ground, left open, need to drive them with appropriate signals according to protocol?
  2. If I care only about uni-directional connection can I connect only RxD or TxD?
  3. What are the consequences of not using/connecting certain signals. What software on PC side expect to have those signals? What functionality will be lost?

NOTE 1: I am using here word "connect" in sense of logical connection -> for electrical connection I would require level shifter circuitry such as MAX232)
NOTE 2: I am pin limited on uC - I do not mind connecting any signals on the board (like pulling them up/down).

\$\endgroup\$
  • \$\begingroup\$ A side note, since you need a level shifter for RS232 anyway you could think about uart to usb chip instead (ftdichip.com/Products/ICs/FT232R.htm) since it is way easier to find a pc with usb... \$\endgroup\$ – Johan Apr 20 '11 at 7:43
13
\$\begingroup\$

It will depend of the software that you're using.

A) In my case, as I develop my own PC software, I've never used other pins, only RxD, TxD and GND. So, in this case you can left other pins open. This is called as null modem without handshaking

enter image description here

B) Yes (assuming GND is being considered)

C) Again, it will depend of the software on PC side. Some softwares you can configure to not take care of hardware control. Others will require RTS/CTS handshaking, so you can do a null modem with loop back handshaking

enter image description here

Source of the pictures: RS232 serial null modem cable wiring

\$\endgroup\$
  • \$\begingroup\$ B) No. You need GND shared. \$\endgroup\$ – Robert Apr 19 '11 at 17:57
  • \$\begingroup\$ thx for answer - one more thing should I leave not used inputs floating? \$\endgroup\$ – mazurnification Apr 19 '11 at 20:54
  • \$\begingroup\$ @mazurnification - technically you should not leave the inputs floating. The PC will have pull-ups/pull-downs to protect itself. If your board has the extra signals on the connector not connected, then you don't need to do anything. Make sure your RS232 driver chip has all the inputs set to a level. \$\endgroup\$ – Robert Apr 22 '11 at 13:51
  • 3
    \$\begingroup\$ Normally one would not use a null modem when connecting to an embedded system or peripheral. Instead, the embedded system/peripheral is wired to transmit/receive on opposite pins from the PC so that it can use a straight cable. Null modems are really intended for connecting two PCs together (or very occasionally, two embedded boards). \$\endgroup\$ – Chris Stratton Aug 16 '12 at 18:14
6
\$\begingroup\$

You only have to connect RxD and TxD, and Ground, of course. (If you're using unidirectional communication only Ground and RxD or TxD is required.) The other signals are used for communication with a modem. Most UARTs on microcontrollers don't provide these control signals. I do remember I've seen it on 1 or 2 UARTs of a uC with several more UARTs (though I don't remember which uC it was).

more on the modem thing (FYI):
EIA-232 defines DTE (Data Terminal Equipment, in this case your PC or SBC) and DCE (Data Communication Equipment, often a modem).

DTE-DCE configuration

You have several ways to connect the PCs.

  1. A direct connection, without the modems, uses a crossover cable (RxD on one side is connected to TxD on the other side, and vice versa). You only need those two signals + ground. That's what you use to connect a PC to a SBC.
  2. A modem connection uses the extra signals too, the PC and the modem are connected via a straight through cable (pin 1 connected to pin 1, etc.)
  3. You can set up a connection between two DTEs as if there are modems present, in that case you use a null-modem to connect control signals between DTEs, like RTS from 1 DTE is connected to CTS on the other. This uses a complete wired crossover cable.
  4. A null-modem setup, where the control signals aren't connected between PCs, but you cheat and don't connect RTS to CTS on the other PC, but on your own PC. Other signals are also locally looped back. The result is that like in case 1) only RxD, TxD and Ground are connected between PCs.
\$\endgroup\$
  • \$\begingroup\$ The other lines can also be used to help with coding. You can do stuff like your microcontroller will tell your PC when it is ready to receive data. This can be really helpful when you are having to do some stuff that requires your attention and you can't be interrupted to clear your buffer. \$\endgroup\$ – Kellenjb Apr 19 '11 at 16:46
  • 3
    \$\begingroup\$ You also need GND. \$\endgroup\$ – Robert Apr 19 '11 at 17:56
5
\$\begingroup\$

You must have Tx, Rx, and signal ground at a minimum. While in theory you don't need to Tx if you are only receiving, as a practical matter in many situations, you will need to acknowledge receiving the message. The other pins are used for "hardware handshaking" a permission system where the sending device verifies the receiving device is ready. You can use Xon / Xoff instead (software handshaking). Some devices, serial mice for example, also used the hardware handshaking lines for power.

\$\endgroup\$
1
\$\begingroup\$

Note that it can be possible to get away without using the 232 chip in certain circumstances. This relies on certain slackness in the protocol and abusing some pins in ways they were not supposed to be. Unfortunately, I don't know the circuit off the top of my head but I have used it. I was searching for it when I came across this question. I wouldn't use it in production and I don't know that it works for all connecting RS232 implementations but it was handy when I used it.

\$\endgroup\$
  • \$\begingroup\$ You will however need overvoltage protection, and the ability to invert the signal somewhere either in a software UART, using a inverter, or in a few cases in a configuration bit of a microcontroller UART peripheral. The basic idea relies on most serial ports being able to accept logic level inputs. \$\endgroup\$ – Chris Stratton Aug 16 '12 at 18:18
1
\$\begingroup\$

For a minimum number of signals it is entirely possibly to make a UART interface using only two wires - a bidirectional signal line, and ground. What is required is that the line drivers on each end be able to be disabled (tri-stated) and that the software implement a take-turns protocol; often the slave device only transmitting to answer a question from the master.

In a logic level connection between microcontrollers (no line drivers) the hardware is quite simple, since you can almost always tristate the transmit pin (possibly by switching it back to GPIO mode).

While the technique is not very frequently used on nearby peripherals, it is quite common using differential signalling as RS485, and may involve a network of many nodes instead of just two. But software schemes designed for talking on an RS485 bidirectional pair will work just fine between two devices connected with a single ended (non-differential) circuit, provided that the distance/noise level does not require a differential solution. Of course this would not strictly speaking be RS232, but a custom extension thereof.

\$\endgroup\$

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.