My ARM AEB-1 development board came with a DB-9 null-modem serial cable. Why?

Having just ordered an Olimex LPC-P2138 ARM development board, I wondered what kind of serial cable I would need. Since this has always confused me, I did a little research.

RS-232 was invented to connect large computers with communication devices – not, as some might think, with terminals. The standard defines a cable with two endpoints: a DTE, and a DCE. The DTE is data terminal equipment – ie, your computer or terminal. DCE is data communications equipment – ie, your modem, or whatever is connecting your large machine to the outside world.

To reduce confusion (but it has had the opposite effect), they defined the connectors and wiring such that these endpoints couldn’t be confused. A DTE is always wired with a male connector (initially DB-25; now more often DB-9); a DCE is always wired with a female connector. The cable to connect them is wired straight-through (pin 1 wired to pin 1, pin 2 to pin 2, etc), with a male connector on one end and a female on the other.

So, how do you connect your computer directly to your terminal, without an intervening modem? Now we need some way to connect two DTEs, so our cable is going to have two female ends, and be wired “funny”. This kind of cable is called a “null modem” cable because it acts like a non-existent (null) modem connecting the two DTEs.

What do I mean by “funny”? To explain that, we need to talk about the signals, their names, and another decision that made sense at the time but that hasn’t reduced confusion.

Signal names in RS-232 are “relative” to – that is, they are named from the perspective of – the DTE, so the pin called “transmit data” means “carry a signal from the DTE to the DCE”; and “receive data” means “carry a signal from the DCE to the DTE”. The decision has that caused confusion is that the signals have the same names on both ends, even though on the DCE end their direction is often reversed. For example, the DCE transmits on the “receive data” line, because that’s the line that the DTE is listening on!

With that short introduction, here are the signals on a DB-9. I don’t care about DB-25s, and neither should you. ;-)

  1. Carrier detect (CD)
  2. Receive data (RXD)
  3. Transmit data (TXD)
  4. Data terminal ready (DTR)
  5. Signal ground
  6. Data set ready (DSR)
  7. Request to send (RTS)
  8. Clear to send (CTS)
  9. Ring indicator (RI)

And what do the connectors look like? Looking at the pins of a male DB-9 they are numbered like this:

  \  1   2   3   4   5  /
   \   6   7   8   9   /

To mate properly with it, the female has to be numbered thus:

  \  5   4   3   2   1  /
   \   9   8   7   6   /

If you look closely (and aren’t too old) you can see the little numbers next to the pins or sockets.

A couple of notes.

Back to our “funny” cable. Instead of being wired straight-through, a null-modem cable is wired something like this (there are variations – this is the cable that came with my ARM AEB-1):

  1  --  4
  2  --  3
  3  --  2
  4  --  1
  5  --  5
  7  --  8
  8  --  7

Pins 6 & 9 were not connected.

Wiring the cable this way connects TXD on one end to RXD on the other. Since both DTEs are going to be “talking” on TXD and “listening” on RXD, this is the only way they will be able to hear each other.