Serial Port
Introduction
A Serial Port is the generic term for a port on a computer that can be connected to other devices. This may be a proprietary connector with a few wires in it; an AppleBus/AppleTalk connector to connect a printer, modem or another computer; or even an Ethernet port. But by far the most common usage is for an RS-232 port with a 9-pin D-connector (DE-9) for asynchronous communications (see Communications). All these ports have one thing in common: the data is sent over a small number of wires (usually one in each direction) in serial fashion, rather than all at once in parallel.
But since "Serial Port" is usually used to refer to the COM Port that is found on the PC (to distinguish it from the rarely-seen-nowadays "Parallel Port"), this page will concentrate on that. Refer to the specific pages for other port types. This page will cover the physical port itself, its signals and how they're commonly used, and the most common protocol used on this port.
Physical Port
The original IBM PC computer came with two communication ports: a parallel port for connection to a printer, and a serial port to connect to a modem for external communications. Of course, over time those ports were used for other purposes, but that was their original intended usage.
Confusingly, both ports used the then already established standard connector called the DB-25.
- The D-series range has (usually) two columns of pins offset from each other to provide both ease of connection, and a definite polarity to the plug to prevent it from being plugged in upside down. Anecdotally, it was so-named because the metal shielding shroud protecting the pins looked like the letter 'D'.
- The letter after the 'D' indicates the layout of the pins; and often the number of them, making the suffix number redundant. For example, the first in the series is the DA-37, followed by the DB-25. The later DE-9 was adopted for COM ports on the IBM PC-AT, since only 9 of the 25 defined serial port pins were used.
To prevent plugging a device into the wrong port, the DB-25s used were different genders: the parallel port was female, needing a male printer cable, while the serial port was male, needing a female modem cable.
DB-25
IBM used the DB-25 connector to match other computing products that it was selling. The existing layout allowed for multiple serial ports within the one connector - the so-called Primary and Secondary ports. It also had clock pins for high-speed Synchronous ports as well. But for the IBM PC, only the Asynchronous Primary port pins were used, which meant only 9 of the 25 pins were needed.
DE-9
In the later IBM PC "Advanced Technology" (AT), they used the smaller DE-9 connector for more flexible port layout on the rear of the PC.
Signals
The standard signals on the Serial Port were designed to talk to an external serial communications device called a MoDem (Modulator/Demodulator), to allow the computer to be connected over long-distance wires - telephone, ISDN or other long haul methods. The signalling conventions for modems had been well established, and required multiple control signals as well as the simple data in and data out wires.
The naming conventions identified the two endpoints of the cable as Data Terminal Equipment (DTE) and Data Communications Equipment (DCE) for computer and modem respectively. The signal names don't usually refer to these, but their definitions do: for example, Transmit Data (TX or TD) is defined to be "Data sent from the DTE to the DCE" - which means the TX pin on the modem is an input pin!
Electrical
The signals used for the normal IBM PC COM port are defined by the RS-232 standard - but there are other standards such as RS-422 and RS-485. These are better for longer cables, or in (electrically) noisier environments; places that electrical interference can change the signal being communicated.
RS-232
RS-422
RS-485
Pinout
These pinouts are identical for both the computer (DTE) and modem (DCE), thus only a straight-through cable is required - but remember that the names are computer-centric.
| Pin name | Abbreviation | DB-25 pin | DE-9 pin | Original function |
|---|---|---|---|---|
| Shield | 1 | - | Tied to the cable shield on ONE end, to shield the whole cable | |
| Ground | GND | 7 | 5 | Signal ground reference |
| Transmit Data | TD | 2 | 3 | Data from the DTE to the DCE |
| Receive Data | RD | 3 | 2 | Data from the DCE to the DTE |
| Data Set Ready | DSR | 6 | 6 | Set HIGH by the DCE to indicate it has power |
| Ring Indicator | RI | 22 | 9 | Pulsed by the DCE to indicate an incoming call |
| Data Terminal Ready | DTR | 20 | 4 | Set HIGH by the DTE to request link establishment |
| Data Carrier Detect | DCD | 8 | 1 | Set HIGH by the DCE to indicate it has a connection to the remote modem |
| Request To Send | RTS | 4 | 7 | Set HIGH by the DTE to indicate it has data to send |
| Clear To Send | CTS | 5 | 8 | Set HIGH by the DCE to allow the DTE to send |
Usage
The original usage of these signals were for very simple electrical "slave" DCEs to be connected to the barely more intelligent "master" DTEs, so to establish a communications link required a sequence of steps. As modems became more sophisticated, a lot of the functions became commands over the data link versus dedicated signals - and yet the signals remained. Still later, the Serial Port was used for communicating with local devices rather than modems, and the line between DTE and DCE blurred so that no true "master" was obvious - and yet the signals remained. Indeed, their functions were redefined to better suit the requirements of the local environment, so that the signals became flow controllers rather than requesters/granters.
Original
The original sequence of steps to communicate with a modem were as follows:
- The DCE raises DSR to tell the DTE that it is able to be used.
- Link establishment: EITHER
- The DTE raises DTR to tell the DCE to establish a link;
- The DCE pulses RI to indicate an incoming call;
- The DTE raises DTR to tell the DCE to accept the incoming call.
- The DTE raises RTS to request transmission
- The local DCE starts transmitting a carrier to the remote DCE
- The remote DCE raises DCD to its DTE, to indicate the carrier has been detected
- The local DCE raises CTS to indicate that the link is ready for transmission.
OR
At this point, a link has been established, but no data can be transmitted or received.
Before data can be transmitted:
Note that, depending on whether the modem is half-duplex or full-duplex, the RTS/CTS/DCD signalling may not be able to be performed in both directions simultaneously. For example, if the modems were connected to a radio transmitter/receiver pair that were operating on the same frequency, the fact that DCD was raised meant that the frequency was already in use, and raising RTS would have no effect.
Null Modem
To remove the modem from between two computers, a full "null modem" cable was required to be wired, to emulate what an instant-response modem would look like: for example, raising RTS would instantly raise CTS in response, while simultaneously telling the other computer that data was about to come.
GND -------------- GND DTR ------\/------ DTR DSR ------/\------ DSR TX ------\/------ TX RX ------/\------ RX /------- DCD / RTS ----/ /--- RTS CTS ---/ /---- CTS / DCD -------/
This is most definitely a full-duplex cable - but is NOT suitable for today's "null modem" cable, detailed below.
Local link
Where the two computers that need to communicate are so close that no modem is required, a direct can be used instead. Here, there is no "prepare channel for transmission" requirement: the link is assumed available all the time. So, at minimum, the two grounds need to be connected, and each Transmit Data pin is connected to the other's Receive Data pin.
However, the remote computer is a limiting factor: it may not be ready to receive. Thus the above signal definitions are modified so that the local computer raises RTS to indicate that it is ready to receive rather than send, and that the cable connects RTS to the remote computer's CTS - which still means "Clear To Send".
Null Modem
This, then, is the current definition of a "null modem" cable. It swaps the relevant pins, and one computer can tell the other to pause transmitting while it catches up:
GND -------------- GND TX ------\/------ TX RX ------/\------ RX RTS ------\/------ RTS CTS ------/\------ CTS