PC serial ports, also known as communications ports, comm ports, asynchronous ports, or async ports, connect slow bit-oriented peripherals such as modems, mice, printers, and plotters to the fast, byte-oriented system bus. Serial ports may reside on motherboards or expansion cards, or be embedded on devices such as internal modems. PC serial ports haven't changed much over the years, although they're faster now and have larger buffers.
Serial ports were formerly used to connect almost anything to a PC?modems, mice, printers, plotters, etc. Nowadays, serial ports are used mostly to connect modems and other peripherals (such as the Palm cradle) that do not require high-speed communications. Serial ports have been replaced for most purposes by USB ports, but most current motherboards and PCs have one or two serial ports, although one or both may exist only as header pins on the motherboard, rather than as visible ports on the rear panel connector. Despite its obsolescence, though, using a serial port is sometimes the best (or only) way to get the job done. The following sections describe what you need to know to use serial ports effectively.
|
Because they transfer only one bit at a time, using serial communications interfaces to establish a unidirectional connection between two devices in theory requires only one data circuit. This circuit comprises one data (or signal) wire and a second wire (called the ground, return, or common) that completes the electrical circuit. In practice, most PC serial communications devices use additional wires to enable bidirectional communication, to provide control circuits between the devices, and so on.
Serial port interface and signaling specifications are defined by the Electronic Industries Association (EIA) standard Interface Between Data Terminal Equipment and Data Communication Equipment Employing Serial Binary Data Interchange, Revision D. This standard is properly abbreviated EIA-232D, but is usually called RS-232C, for the earlier and nearly identical revision C. The ITU (formerly CCITT) defines essentially identical standards as V.24 (interface) and V.28 (signaling).
EIA-232D defines pin assignments, but does not specify physical connectors. In the PC environment at least, a well-established de facto standard does exist for 25-pin serial connections. By convention, DTE devices (e.g., PC serial ports) use a 25-pin male D-sub plug connector, designated DB25M. DCE devices (e.g., modems) use a 25-hole DB25F female socket connector. There are exceptions. For example, some serial printers are DTE devices but use a DB25F connector. Figure 22-1 shows a DB25 connector.
Table 22-1 lists DB25 pin assignments. The column headings are self-explanatory, except the following:
Signal direction, relative to the DTE. For example, a DCE (modem) asserts voltage onPin 5 (CTS) to notify the DTE (serial port) that it is ready to accept data from the serial port. We list this signal direction (from the DCE to the DTE) as In. Pins 1 and 7 are ground pins, and have no signal direction. Pin 11 is unassigned, and so has no signal direction.
The circuit numbers/names used by CCITT, EIA, and RS standards documents, respectively. Circuits with a hyphen (-) are defined by the standard in question but not assigned a name. Circuits with a blank box are neither defined nor named.
Pin |
I/O |
CCITT |
EIA |
RS |
Common name(s) |
Abbreviations |
---|---|---|---|---|---|---|
1 |
- |
101 |
- |
AA |
Chassis Ground |
GND |
2 |
Out |
103 |
BA |
BA |
Transmit Data |
TD, TxD, SOUT |
3 |
In |
104 |
BB |
BB |
Receive Data |
RD, RxD, SIN |
4 |
Out |
105 |
CA |
CA |
Request To Send |
RTS |
5 |
In |
106 |
CB |
CB |
Clear To Send |
CTS |
6 |
In |
107 |
CC |
CC |
Data Set Ready |
DSR |
7 |
- |
102 |
AB |
AB |
Signal Ground |
SG |
8 |
In |
109 |
CF |
CF |
Data Carrier Detect, Carrier Detect, Receive Line Signal Detect |
DCD, CD, RLSD |
9 |
In |
- |
- |
Test Voltage (+12V) | ||
10 |
In |
- |
- |
Test Voltage (-12V) | ||
11 |
(unassigned) | |||||
12 |
In |
122 |
SCF/CI |
SCF |
Secondary Data Carrier Detect |
SDCD |
13 |
In |
121 |
SCB |
SCB |
Secondary Clear To Send |
SCTS |
14 |
Out |
118 |
SBA |
SBA |
Secondary Transmit Data |
STD |
15 |
In |
114 |
DB |
DB |
Sync TX Timing DCE (Transmit Clock) |
TC |
16 |
In |
119 |
SBB |
SBB |
Secondary Receive Data |
SRD |
17 |
In |
115 |
DD |
Sync RX Timing DCE (Receive Clock) |
RC | |
18 |
In |
LL |
Local Loopback |
LL | ||
19 |
Out |
120 |
SCA |
SCA |
Secondary Request To Send |
SRTS |
20 |
Out |
108.2 |
CD |
CD |
Data Terminal Ready |
DTR |
21 |
In |
110 |
CG |
CG |
Signal Quality |
SQ |
22 |
In |
125 |
CE |
CE |
Ring Indicator |
RI |
23 |
In/Out |
111/112 |
CH/CI |
CH/CI |
Data Signal Rate / Speed Indicator |
DRS / SI |
24 |
Out |
113 |
DA |
DA |
Sync TX Timing DTE (Transmit Clock) |
XTC |
25 |
In |
TM |
Test Mode |
EIA-232D maps circuits, all of which are named from the point of view of the DTE device, to pin numbers. Placing a voltage signal on a circuit is called asserting or raising that circuit. For example, placing voltage on Pin 20 asserts (or raises) DTR. Although you probably don't need to understand these signals in detail, knowing something about their purposes will help you choose the right cable and troubleshoot connection problems. The signals asserted on the EIA-232D pins and pin pairs commonly used in PC serial communications have the following purposes:
Pin 1, if present, grounds one end of the cable shield to the equipment chassis to reduce interference. Pin 7 is the common ground reference for all signals on other pins. Pin 7 must be connected at both ends for communication to occur. It is a relatively common (although poor) practice for cables to connect the grounds together, forming a single circuit.
These pins are used to communicate data. A DTE device transmits data on Pin 2 and receives on Pin 3. A DCE device transmits on Pin 3 and receives on Pin 2. Pin 7 is the common return and ground reference for both of these circuits.
The DTE asserts RTS when it wants to send data to the DCE, and the DCE asserts CTS when it is ready to receive data. The DTE may not transmit data until the DCE asserts CTS. CTS may be linked to RTS, allowing the DTE to use RTS to assert CD, if the DCE is so configured.
The DCE device asserts DSR when it is powered on and not in test mode. The DTE asserts DTR when it is powered on. In modem applications, DTR may be used to emulate an off-hook condition. If the modem is in auto-answer mode, RI may be linked to DTR, causing DTR to be asserted and the modem to answer when an inbound ring is sensed.
Although the proper name of this circuit is Received Line Signal Detector (RLSD), nearly everyone calls it Data Carrier Detect (DCD) or simply Carrier Detect (CD). The DCE asserts CD to tell the DTE that a carrier is present at the DCE. In modem applications, this means that the DCE is receiving a telephone line signal that meets its criteria for presence of a carrier. Many DTE devices will not transmit or receive data unless the DCE is asserting CD. Accordingly, in nonmodem (direct connect) applications, Pin 8 (CD) is normally tied to Pin 20 (DTR). Because the DTE normally asserts DTR as soon as it is turned on, this "spoofs" the DTE into believing that DCD has been asserted.
The DCE asserts RI to notify the DTE that the phone is ringing. When configured in auto-answer mode, the modem (DCE) asserts RI in step with the ring cadence. That is, when ring voltage is present, the DCE asserts RI; between rings, the DCE drops RI. The DTE instructs the DCE to answer the call by asserting DTR on Pin 20.
PCs commonly use nine of the preceding 10 pins and signals (excluding Pin 1, GND). Pins 12 through 17, 19, 21, 23, and 24 are not used for standard PC serial connections, but may be used in nonstandard ways by proprietary serial devices. Most commercial DB25 serial cables are labeled as "9-wire," "10-wire," or "25-wire." The first connects only the most commonly used pins. The second also connects GND. The third connects all 25 pins.
When IBM introduced the PC/AT in 1984, it used a nonstandard DB9M 9-pin serial connector that included only the commonly used pins. Because this connector is physically smaller, it allowed putting both a serial port and a DB25F parallel port on the same expansion card bracket. The market presence of IBM and the passage of years have combined to make this DB9M serial connector a de facto standard. Like the DB25, DB9 connectors are available in male and female versions, designated DB9M and DB9F, respectively. By convention, DTE devices use the DB9M. Few DCE devices use DB9 connectors. However, those that do usually use a DB9F. Figure 22-2 shows a DB9 connector.
Although its pinouts don't map to either DTE or DCE, the DB9M serial connector is considered an "honorary" DTE device, with DTE-to-DCE interfacing accommodated by the cable. The DB9 connector includes the nine important signals, but the pinouts differ from DB25, as Table 22-2 shows.
Pin |
I/O |
CCITT |
EIA |
RS |
Common name(s) |
Abbreviations |
---|---|---|---|---|---|---|
1 |
In |
109 |
CF |
CF |
Data Carrier Detect, Carrier Detect, Receive Line Signal Detect |
DCD, CD, RLSD |
2 |
In |
104 |
BB |
BB |
Receive Data |
RD, RxD, SIN |
3 |
Out |
103 |
BA |
BA |
Transmit Data |
TD, TxD, SOUT |
4 |
Out |
108.2 |
CD |
CD |
Data Terminal Ready |
DTR |
5 |
- |
102 |
AB |
AB |
Signal Ground |
SG |
6 |
In |
107 |
CC |
CC |
Data Set Ready |
DSR |
7 |
Out |
105 |
CA |
CA |
Request To Send |
RTS |
8 |
In |
106 |
CB |
CB |
Clear To Send |
CTS |
9 |
In |
125 |
CE |
CE |
Ring Indicator |
RI |
The Universal Asynchronous Receiver-Transmitter (UART) is the heart of a serial port. When transmitting, the UART receives the outbound byte stream from the system bus, converts the bytes into a bit stream, and places the bits onto the serial interface. When receiving, the UART receives an inbound bit stream from the serial interface, buffers the inbound bits, assembles them into bytes, and places those bytes onto the system bus. There are two types of UARTs.
A dumb UART generates an interrupt each time it sends or receives a byte. At low data rates this is acceptable, but at faster data rates these frequent interrupts put a heavy burden on the processor. Dumb UARTs have long been obsolete, but are often encountered in older systems such as 486s and Pentiums that have been converted to use as firewalls, fax servers, and other communications servers. Dumb UARTs can be used with Windows and Linux in applications for which data rates do not exceed 38.4 kb/s?e.g., 14.4 kb/s fax modems. The following are dumb UARTs:
The 8250 is an eight-bit UART used in original IBM PCs and compatibles, and occasionally encountered in newer PCs with secondhand serial cards installed. If you find an 8250, pull the card and throw it away.
The 16450 is a 16-bit UART used in PC/ATs and compatibles. It is common on 16-bit serial cards for 80286, 80386, and early 486 systems, and on the motherboards of such systems. It runs 19.2 Kb/s reliably, and may be usable at 38.4 Kb/s. It has only a one-byte buffer, making it unsuitable for multitasking operating systems such as Windows 9X/2000/XP and Linux. The 16450 may exist as a discrete chip on the system board or an expansion card, or as a part of a VLSI chipset. If the 16450 is socketed, you can replace it directly with a $5 16550AFN chip. If the 16450 cannot be replaced easily, disable it and install a modern serial card.
The 16550 is a 16-bit UART used in late-model 486 systems, in Pentium and later systems, and in expansion cards intended for those systems. The 16550 has a 16-byte FIFO buffer, but early models have a bug that disables the FIFO buffer. This bug was fixed in later models of the 16550. Fixed versions are designated 16550A, but some chip makers did not change the labeling, making it difficult or impossible to discriminate visually between buggy models and fixed models. Windows (usually) reports an early 16550 as a 16450. Linux reports an early 16550 as a 16550, and a 16550A (regardless of labeling) as a 16550A. Early 16550 UARTs are unacceptable for multitasking use under Windows or Linux.
The 16650 is a faster 16550-class UART that doubles buffer size to 32 bytes. Unfortunately, like early 16550 models, early 16650 models have a bug that disables FIFO buffering. Linux and Windows treat these early 16650 UARTs as 16450s, using only one byte of the buffer. Windows reports the 16650 as a 16550 or 16650, regardless of whether the 16650 is an older, buggy model or a later, fixed model. However, Windows generally refuses to enable the FIFO buffer on an older 16650. Linux, as usual, reports the UART type accurately. If Linux reports the UART as 16650, it is an older model and should not be used for multitasking or high data rate applications. If Linux reports the UART as 16650V2, it is a fixed model and can be used.
A FIFO UART uses a first-in, first-out buffer to reduce the number of interrupts that occur when transferring data. The FIFO buffer may range from 16 bytes to 64 bytes or more. A FIFO UART buffers incoming data until the buffer reaches the trigger level (is nearly full). The UART generates an interrupt only when the trigger level is reached, which means a FIFO UART generates many fewer interrupts than a dumb UART and is much less likely to drop incoming data bytes. The following are FIFO UARTs:
16550-family UARTs use a 16-byte FIFO buffer to support multitasking operating systems, which cannot always give immediate attention to interrupts generated by the serial port. Early 16550 models had a bug that prevented the FIFO buffer from being used. This bug was fixed in later models, which are officially designated 16550A. However, some chip makers produced fixed 16550s without changing the labeling, making it difficult or impossible to tell visually whether the UART is the buggy older model or the fixed newer model. Windows usually reports an early 16550 as a 16450, and uses it as though it were a 16450. Linux reports the buggy early model as a 16550, and the fixed newer model as a 16550 (regardless of how the chip is labeled). The 16550A functions properly under Windows and Linux, and supports 115 Kb/s throughput. The 16550A is the minimum acceptable UART for a modern system.
The 16650 is essentially a faster 16550-class UART that doubles buffer size to 32 bytes and adds support for various modern BIOS features, including power management. Early 16650s suffer the same bug as early 16550s, and cannot be used reliably for multitasking or high data rates under Windows or Linux. It is usually impossible to tell visually whether a particular 16650 is the older, buggy model or the newer, fixed model. Windows generally disables the FIFO buffer on a buggy 16650, but enables the buffer for a fixed 16650. Linux reports an original 16650 as a 16650, and the fixed model as a 16650V2. The 16650 supports data rates up to 450 Kb/s, making it better suited than a 16550 for use with ISDN adapters and similar high-speed devices. Dual-16650 serial cards are available for less than $50.
The 16750 is an improved 16550-class UART that further expands the FIFO buffer to 64 bytes for transmit and 56 bytes for receive, and increases the maximum data rate to 900 Kb/s. The 16750, as well as similar enhanced versions such as the 16850 and 16950, are uncommon on PCs, and are used primarily on specialized, very high-speed devices such as T3 interface cards.
Under DOS and Windows 9X, you can determine the UART type with Microsoft Diagnostics (MSD.EXE), with a general-purpose diagnostic utility such as SiSoft Sandra, or with a dedicated port diagnostics program such as PortMaster. Either of the latter two utilities can be downloaded from any of numerous Internet sites.
Figure 22-3 shows SiSoft Sandra displaying information about COM1 on an AMD Duron system, built on a Microstar motherboard that uses a VIA KT133 chipset, and running Windows 98. Sandra reports that COM1 uses a National Semiconductor 16550AN UART, which is not precisely true. The COM1 UART is actually just one of the functions provided by the Super I/O portion of the Southbridge of the VIA chipset. The UART is emulated rather than physically present, but as far as Windows and connected serial devices are concerned, this system might just as well have a real physical 16550AN UART.
Utilities that run under Windows NT/2000/XP are limited in the amount and accuracy of the information they can provide because Windows masks the underlying hardware from the utility. For example, Figure 22-4 shows the results of running SiSoft Sandra Ports Information on a system running Windows NT 4. The Windows NT Hardware Abstraction Layer (HAL) prevents user-mode applications (such as Sandra) from accessing the underlying hardware, so Sandra can report only what Windows sees fit to tell it, which may be little or nothing.
If your system boots Windows NT/2000/XP, the only way to obtain detailed information about the hardware is to boot DOS and run a DOS-mode diagnostic utility. You can use either a comprehensive commercial diagnostics program such as CheckIt for that purpose, or a dedicated small utility such as PortMaster.
If the device has not yet been installed in the computer (or if you're willing to pop the lid), you can sometimes determine the UART type by examining the chips on the device to locate a UART number. However, many devices use VLSI/ASIC components rather than discrete UART chips, making it difficult or impossible to identify the UART type visually. In these cases, if you don't have the documentation, the only convenient way to determine the UART type may be to install the board, boot DOS, and run a diagnostics program.
Some "enhanced" VLSI/ASIC-based 16450 serial ports with FIFO buffering added may falsely report themselves to the operating system and applications as 16550s, although PortMaster usually detects them properly. These UARTs are commonly found on early 486 motherboards and "high-speed" serial cards designed for 486 systems. These bumped-up 16450s may or may not function properly with any particular combination of operating system and application, and should be replaced with a serial port that uses a 16550AFN or higher UART.
Which UART you need to use for maximum throughput depends on three factors:
DCE-to-DCE rate specifies the actual link speed between the two communications devices. For example, V.90 "56K" modems actually talk to each other at a maximum of 53 Kb/s (rather than 56 Kb/s, due to FCC regulations limiting signal amplitude on a phone line). ISDN devices communicate with each other at 64 Kb/s when using one B channel, or 128 Kb/s when using two, and so forth.
Data compressibility is the degree to which source data can be compressed by the communications device before being placed on the DCE-to-DCE link. Some data (e.g., text, web pages, and databases) contains a great deal of embedded slack space, and can be compressed as much as 4:1 by the communications hardware. Other data (e.g., images, executables, etc.) is much less compressible.
DTE-to-DCE rate specifies the actual link speed between the local serial port and the local communications device. Setting this speed faster than the DCE-to-DCE rate allows the serial port to provide compressible data to the communications device quickly enough that the DCE-to-DCE link never runs out of data to transfer. The compression algorithms used by most communications devices allow 4:1 compression in theory, although 1.5:1 or 2:1 is more common in practice. This means that the DTE-to-DCE data rate must be at least one and one-half or two times the DCE-to-DCE rate (and, ideally, four times) to make sure the DCE is never kept waiting for data.
After you determine the UART types used by your serial ports, use the following guidelines to decide if these ports are adequate for their intended purpose:
Serial ports that use these UARTs are long obsolete, and are completely unsuitable for use in any modern system. 8250-class UARTs were used on original IBM PC- and XT- class systems, and 8250-class add-on cards were installed in some 486 and early Pentium-class systems. Replace any serial port that reports an 8250-class UART. If the UART is embedded in the motherboard, disable the motherboard serial port(s) in BIOS Setup, and install an add-on serial card with 16550AFN or higher UARTs.
These ports are usually adequate for mice and similar low-speed devices, even on slow and/or heavily loaded computers.
These ports are usually adequate for modems that use V.32bis (14.4 Kb/s), V.34 (28.8 Kb/s), or V.34+ (33.6 Kb/s). These ports are marginal for V.90 (56 Kb/s) modems, and single-channel (56/64 Kb/s) ISDN applications because they allow for only about 2:1 compression. A 16550A is unacceptable for dual-channel ISDN because it limits the DTE-to-DCE rate to 115.2 Kb/s, which is actually lower than the 128 Kb/s DCE-to-DCE rate. All other things being equal, 16550A ports are less likely to be a bottleneck on faster and lightly loaded computers. On midrange 486s and less, and on heavily loaded slow Pentiums, the 16550A may be a bottleneck, and should be replaced with a 16650.
These ports are necessary to guarantee full throughput potential for any application that requires a DTE-to-DCE rate higher than the 115.2 Kb/s DTE limitation of the 16550A and slower UARTs. In other words, you really need a 16650 or better for anything above a 28.8 Kb/s V.34 DCE-to-DCE link. In practice, you probably won't notice much difference with anything up to a 56K modem, but you may notice a big difference with ISDN.
Each standard serial port requires an IRQ and an I/O port. The serial port generates an interrupt on its assigned IRQ to get the processor's attention when it has data to transfer. The I/O port is a range of addresses, named for the first address in the range, that defines a "scratchpad" area that the serial port uses to exchange data with the computer. For example, I/O Port 0x3F8 includes the address range 0x3F8 through 0x3FF.
Serial ports are named COM[xxx]:, where [xxx] may be a number from 1 through 256. Although the serial port name technically includes the trailing colon, the colon is usually dropped for convenience, and that is the practice we follow. IBM originally defined only COM1 and COM2 for the PC BIOS, although it later defined standard values for COM3 and COM4 as well. Table 22-3 lists the standard COM port assignments for ISA/PCI systems. (Systems that use the EISA or MCA bus use additional COM ports with different settings, but these systems are obsolete and immaterial.) The values for COM1 and COM2 are invariant due to long usage. The values for COM3 and COM4 are semistandard, but may differ on some systems.
Port Name |
Base address |
I/O port range |
IRQ |
---|---|---|---|
COM1 |
0x3F8 |
0x3F8 - 0x3FF |
4 |
COM2 |
0x2F8 |
0x2F8 - 0x2FF |
3 |
COM3 |
0x3E8 |
0x3E8 - 0x3EF |
4 |
COM4 |
0x2E8 |
0x2E8 - 0x2EF |
3 |
Note that ports 1 and 3 and ports 2 and 4 share an IRQ. Although EISA and MCA systems permit IRQs to be shared gracefully, ISA/PCI systems do not. This means that, in effect, you can use only two serial ports safely on a system that uses standard COM port assignments. You may be able to get away with such sharing?say, by putting a serial printer on COM3 and a mouse on COM1?but you must make sure never to use both devices that share one IRQ at the same time.
Windows 95 went a long way toward solving this problem by adding support for up to 128 COM ports. Windows NT 4.0 goes further still, supporting up to 256 COM ports and allowing you to define custom values for IRQ and base address for each installed COM port. Because Windows applications use COM ports by name and are not concerned with underlying settings, it is relatively straight-forward to support multiple COM ports in the Windows environment.
A final note: PCs assign a priority to each IRQ, and process interrupts on the higher-priority IRQ first. The highest-priority IRQ is 0, followed by 1, 2 through 9, 10 through 15, and then 3 through 8. Put high-priority devices such as modems on a high-priority serial port (e.g., COM2/IRQ3) and low-priority devices such as mice on a lower-priority serial port (e.g., COM1/IRQ4). This is less important with recent UARTs than it used to be, but is still worth doing as a matter of good practice.
The proliferation of high-speed external serial devices, notably serial ISDN terminal adapters, made it obvious that something faster than the standard 16550 UART was needed. The standard serial ports on most PCs top out at 115 Kb/s or (rarely) 230 Kb/s. That's not fast enough to support the full throughput of a dual B-channel ISDN terminal adapter, which operates at 128 Kb/s natively and up to four times that fast when data compression is enabled.
To address that need, various manufacturers supply enhanced serial ports, which are add-on cards that include one or two serial ports. These use 16650, 16750, 16850, or 16C950 UARTs, which are essentially 16550 UARTs with additional buffering added and support for higher data rates. Some cards also include an embedded processor, typically an 80186 or 80286, which offloads interrupt handling from the main processor.
These adapters are overkill for normal serial port applications, may provide some benefit for 56K dial-up modems, and often provide a noticeable performance increase for ISDN applications. If you buy such a card, make sure that it includes any necessary drivers for your operating system.
Each standard serial port occupies one IRQ, which limits how many standard serial ports can be installed. Most computers need one or two serial ports at most, so this is seldom a problem. But there are applications?such as running a terminal server under Linux?for which it is desirable to have eight, 16, or more serial ports available. That's clearly impossible if each serial port requires one IRQ. The solution is a special board called a multiport serial adapter.
These adapters are available in ISA and PCI form, and are installed in the PC just like any other expansion card. They provide from four to 32 serial ports using only one IRQ. The serial port connectors reside in a separate external box that connects to the multiport serial adapter via multiple 8P8C ("RJ-45") connectors or a single proprietary octopus cable with many conductors.
Such adapters are available in two forms: "dumb" multiport serial adapters are little more than a collection of UARTs and connectors, use 8-bit transfers, generate an interrupt for each byte transferred, and depend on the host PC for processing power. "Smart" multiport serial adapters include a microprocessor (typically an 80286 or 386) that offloads serial interrupt processing tasks from the host PC. Smart adapters usually buffer 1 KB of data or more between transfers, greatly reducing the interrupt burden on the host system. Nowadays, most multiport serial adapters are of the smart variety.
Dumb terminals have become rare in most applications?LAN-connected PC clients are much more common nowadays, even on Linux systems?and so the need for multiport serial adapters is much less than formerly. If you do need one, for example, for process control, automation tasks, or building a terminal server for a modem pool?make sure that drivers are available for your operating system.