Cable
&
Communication
 Networks
Index - Cables & Communication
RS232
Index- Serial 
 PC Serial Ports
RS232 serial communications is very widely used in the computer and communications industry to interconnect equipment. It was therefore natural that when the first PCs appeared in 1981 they provided one or two serial ports to allow printers and other devices to be connected. The ports are normally called "COM-1" and "COM-2". In principle a PC can support as many as 7 COM ports, and a PS/2 can support 4 (Norton p227)

Mice and modems are the main use for RS232 ports, but they have also been used for scanners, printers and terminals for multi-user support. The main use remaining is probably industrial instrumentation.

PC serial ports have been losing their function over several years. There are several defects.
 
The design of RS232 cabling and transcievers limits the transmission speed to about 115 kilobaud even with a very short cable - rather too slow to support today's printers and scanners. 
Cables up to 15 metres long can be supported - but the baud rate may then need to be cut back to 9,600 - a 1 megabyte file will take more than 5 minutes to transfer. 
RS232 was never designed as a "plug & play" environment for end users. If an installation does not go as planned quite a lot of technical knowledge is required to put things right.
The cable isn't intended to supply power - so small devices like PC mice use "cheats" to draw a couple of milliamps from the handshake lines

In consumer oriented designs the functions of RS232 are being replaced by Universal Serial Bus (USB). However there are disadvantages to USB - it is much more complex to design equipment for instance. 

Implementing a PC serial port at the design stage now costs very little, and there is still enough use for them that they are likely to be present on equipment for some years yet. 

RS232 General Information
8250 family UART
1488 Line Drivers
1489 Receivers
Outline of this page
Basic Design
Implementation
Circuit
Software

Basic Design

The overall design of a PC serial port is as follows.

The main functionality of the port is provided by an 8250 family UART (8250, 16450, 16550, 16554, 16850 etc). The UART does the following:
 
Converts between the parallel representation of information found on computer internal busses and the serial form used on most communication lines including RS232.
Creates a software setable clock frequency needed by the transmitter and receiver from an external clock signal that is usually 16 times the maximum required speed.
Determines the serial data format - the number of data bits transmitted, insertion and deletion of start, parity and stop bits in the channel.
Provides registers to control the RS232 handshake signals.
Provides interrupt facilities so that the data and handshake registers can gain the attention of the main processor.

The UART provides all the main functions to convert between the PCs internal bus (usually ISA) and the external RS232 port. However there are some other chips involved:
 
Transceiver or "driver" chips are located between the UART data and handshake signals and the outside world. The UART signals are all at standard computer logic levels (TTL). RS232 levels are very different.

The driver chips used with RS232 translate between the bit-levels - so
For logic anything between 0 and  0.8 volts is a logic "0" -  anything between 2 and 5 volts is a logic "1" - and anything beyond or between in "illegal". Voltages below 0.0 volts or above 5.3 volts cause damage. 
For RS232 anything between +3 and +25 volts is logic "0", anything from -3 to -25 volts is a logic "1" - anything outside this range is illegal.

RS232 transceiver chips are usually very straight forward and low cost. Where an Ethernet transceiver detects and reports "illegal" states using its collision pin RS232 devices just behave indeterminately. The low cost of RS232 devices mean they are often used as "sacrificial" chips. If a user does something wrong with the RS232 port the chips will fail - they are sometimes socketed and replaceable. Some serial channel designs have all sorts of elaborate over-voltage protection, but the PC relies on the transciever chips for protection
 

Glue logic - the UART has to be connected to the PC internal bus, but not all of it's logic pins are suited to direct connection. There is usually a data buffer, address decoding and interrupt request generation.

Implementation

The standard PC adapter has two serial ports. The PC ports are usually implemented as 9 pin DTEs (Male) using the IBM standard. Some systems have one 9 pin and one 25 pin connector. There may also be a parallel port on the same circuit board, it is distinguishable from the serial port because it is female.

Serial ports were originally implemented as an adapter - a board that plugs into the PC ISA bus as an "option". Two serial ports became a standard part of every system, so it was then cheaper for manufacturers to integrate them into the motherboard.

In the mid 90s the serial, parallel,  floppy and hard disk controls were all commonly integrated into single "multifunction" chips - either built on an ISA bus board or integrated onto PC motherboards. In software terms early multifunction adapters are identical to older devices made from discrete components but the single chip takes less space and costs less to implement

Almost all PCs now include the basic set of two serial ports as part of the motherboard "chipset".

Serial ports are still available as separate add-in ISA adapters, but this will have to change as PCI entirely displaces the ISA standard. A few manufacturers make PCI multiport serial devices - these aren't cheap, but its a specialist market.

Interrupts

The serial ports on a PC get IRQ 3 and 4. Adding more ISA adapters would mean either using more IRQs or sharing IRQs by using edge triggering. Either approach creates problems, so multiport devices are prefered, rather than using several 2-port adapters.

Multiport adapters designed to support instrumentation or multi-user terminal oriented operating systems such as UNIX have 4, 8 or more serial ports. Large numbers of ports create a further problem because each character exchanged potentially generates an interrupt - so a busy 8 port device might easily generate severl hundred thousand IRQs per second!

Devices with  8 or more high speed ports may need
 
an independent processor to buffer the traffic between the PC and the terminals
substantial FIFO buffering

otherwise the number of interrupts may have a serious impact on the performance of the system. Where a large number of serial ports is required it may be better to use:
 
a USB multiport device - it will have internal buffering.
an Ethernet terminal server such as those made by Specialix or Milan.

Speed

PC serial ports have a limited data transfer speed:
 
By software to speeds not much greater than 9,600 baud. In normal operation the 8250 /16450 UART interrupts the processor every time a character is transmitted or received and as the rate of reception reaches about 1,000 characters per second the interrupt service routines are no longer fast enough. More efficient interrupt routines or polled control of the UART can achieve higher speeds. Most recent PCs use the 16550 UART which has a 16 character FIFO buffer, interrupts less often and can therefore operate at higher speed. 
By hardware to 115,200 baud. The clock for the UART has to be 16 times the required baud-rate. The clock used in PC designs is normally 1.8432 MHz and this sets the highest speed achievable by hardware

The highest transfer speeds are not normally useable with long cables because the cables and transcievers create too many errors. Unless parity checking is used serial ports don't directly report errors - they just turn data to garbage and wait for the problem to be spotted.

Circuit

PC serial adapters are generally designed for the ISA bus. There was little point using a higher
speed bus until recently because nothing on a straight forward serial adapter can use higher data transfer rates. PCI serial devices do, of course, allow for plug & play installation - the automatic setting of I/O and interrupt information. The ISA bus is a 20 year old design and is no longer  implemented in new PCs so the only way to add serial devices into a PC may be PCI.

An outline diagram for one channel of a serial adapter is shown below. At the heart of the device is a 16450 UART -shown in grey outline. This device could easily be replaced with a pin-compatible 16550 device.

A 9-pin D plug is shown at the far right, with the data, flow control and modem control lines in blue. Transmit drivers in this case are 75150s and receivers are 1489s.
 

A serial port needs to exchange three main groups of signals with the host system:

An 8 bit data port is used to connect directly to the lowest 8 bits of the system data bus. If more than 1 UART is present it will be preferable for the system data bus to be buffered, creating a board-bus. (shown in purple as BD-Bus in the diagram above).

I/O Addressing on a PC ISA bus is limited to a 10 bit range. The two standard serial ports occupy 8 bytes in the I/O address map  - COM1 at 3F8 to 3FF and COM2 at 2F8 to 2FF. Address decoding to the individual UART can be arranged in several ways - the diagram shows the mechanism used in a "Wyse" adapter in yellow. Within the UART addresss space the UART TX/RX registers appear at the base address. The UART has 10 registers but these are mapped into the 8-byte range.

Adapters sometimes make some provision for the address of individual ports to be changed - however the flexibility is often not very great. The problem with using non-conventional addresses and IRQs is that special support software may be needed.

Interrupt facilities on the PC ISA bus are limited - there are only IRQ 03 to 15 available. COM1 is normally allocated to IRQ4 and COM2 to IRQ3. Some adapters simply hard-wire these IRQs, others allow selection from a range. (The diagram shows a simple 2-position selection in red)

With the I/O address and IRQ set the 8250 UART appears in the PC I/O map with its 8 normally visible registers extending from the I/O base address.

Software

Program access to the serial ports is normally via the system software and thence via the BIOS.
 
BIOS services are invoked using Interrupt 14 Hex (Decimal 20). 

The serial port number is placed in register DX - 00 Hex indicates COM-1. An "ISA" PC could in principle support up to seven COM ports (Using the equipment list word at address 0040:0010 Hex) However the PS/2 BIOS and the time out-values at 0040:007C Hex in a standard PC allow just four. 

There are four basic services and these are selected through register AH.

The Initialise Port service sets the baud-rate, word-length, stop-bits and parity in accordance with a bit pattern held in register AL. When the service has completed the port status is returned in AX.
 

Service required
in AH (Hex)
Description
00Initialise Port
01Transmit Ch
02Receive Ch
03Port Status
04Initialise Ext
05Control Ext

For more complete info see Norton p227 on.

To transmit a single character the port number is placed in DX and the character to be transmitted in AL. When the service returns it reports a status in AH. If AH is zero the service completed, otherwise bit 7 signifies an error and the other bits indicate what kind of error

To receive a character the port number is in DX when the service is called. The character received (if any) is in AL and AH reports the success or failure of the service.

Service 03 gives a more comprehensive report on port status than services 00 to 02

Service 04 and 05 were used on the PS/2 to control its improved serial ports.

-=-

Microsoft NT Control Panel / Ports shows the settings for each detected port. There are
 
Baud Rate adjustable from 75 to 128,000,
Data Bits adjustable over the range 5 to 8
Parity adjustable to none, even, odd, mark, or space
Stop bits ajustable to 1, 1.5 or 2
Flow control settable to Xon/Xoff, Hardware or None.

Advanced settings allow
 
The COM port number to be set to any value ( 1 through 256!)
Base I/O to be set to default, or a range of specific addresses 2E0, 2E8, 2F8, 3E8, 3F8
IRQ to be set to default or 2,3,4,5,6,7,8,9,10,11,12,13,14,15
FIFO (ie 16550) to be turned on or off

Application software will generally operate via Windows services such as those provided by NT which to some extent isolates users and programmers from the details of the hardware.