Serial Port Drivers

Many embedded systems use serial ports as an interface to the outside world. Despite the serial ports age (it has been around longer than dirt), serial ports are still found on most modern single-board computers. The serial device on an embedded system has two portions: the protocol and the physical interface. The protocol portion takes care of start and stop bits, bits per character, the width of each bit based on a configured baud rate, and the conversion of the serial bit stream into a parallel byte stream easily digested by the CPU. The physical interface takes care of converting voltage levels on the CPU to the voltage levels needed by the interface. In many cases, the physical interface also provides some electrical isolation between the physical connector and the CPU. Embedded systems use two fundamentally different transmission mechanisms for their serial ports: single wire and differential drive transmission.

Single Wire Data Transfer

Single wire systems dedicate one wire to each direction of data transfer and use a common ground reference. While simpler than differential drive transmission, single wire transfer has limitations with regard to transmission speed and the length of the wire from sender to receiver. The most common single wire standard is RS-232. RS-232 is the serial interface used by the COM port on a PC and the TTY ports on UNIX systems. RS-232 is by far the most common serial communications standard in the industry.

image from book
The Many Flavors of RS-232

RS-232 is brought to the external world as a data terminal equipment (DTE) or data communications equipment (DCE) connection. If you want to connect two RS-232 ports together pin-to-pin and you want these two ports to be able to exchange data, one side must be configured as DTE, and one side must be config ured as DCE. This terminology originates from one of the earliest uses of the interface: connecting a dumb terminal port to a modem to provide remote access to a computer. In this scenario, the terminal is the DTE, and the modem is the DCE.

If there werent a DTE and DCE side to the interface and you tried to connect the two devices pin-to-pin (through a cable), the transmitter line on one would be tied to the transmitter line on the other, and the receiver line on one would also be tied to the receiver on the other. This wouldnt be pretty! Configuring one side as DTE and the other side as DCE allows a straight-through cable to connect the two devices. The physical difference between DTE and DCE is the pinout of the con nector. For example, on DTE, pin 2 might be transmit, and on DCE, pin 2 would be receive. Similarly, pin 3 on DTE might be receive, and pin 3 on DCE would be transmit.

So what do you do if you have two devices that both have an RS-232 connection, but both are of the same type? Thats what a null-modem is for. The null-modem does all the required pin swapping through a special cable or a small adapter that is inserted between the cable and one of the device connectors.

image from book
 

Differential Drive Interface

Differential drive is not as widely used. It requires a few more wires, increases the drive length substantially, and also supports transmission speeds in excess of 1MB. Differential drive interface can drive faster signals through greater distances because of its inherent noise immunity. The idea behind differential drive is that opposite polarity signals (a signal and its inverse) are applied to two wires that travel the same path as a twisted pair. These wires are wrapped around each other, which minimizes interference. The receiver determines the state of the signal based on the voltage difference between the two wires. If noise hits the cable, it is likely to inject the same corrupting signal on each wire, so it doesnt contribute to the detected difference (see Figure 1.4).

image from book
Figure 1.4: Differential Drive and Noise Immunity.

The line receiver uses analog techniques to compute A-B, giving (+S+N)-(-S+N)=2S. Thus all induced transmission line noise is cancelled at the receiver.

The most common embedded interfaces that use this technique are RS-422 and RS-485. RS-422 is a differential drive replacement for RS-232. With no other changes in firmware, an RS-232 interface could be replaced with RS-422, and its maximum line drive and line speed would be increased. RS-485 adds the ability to have more than a single transmitter and receiver on the connection. RS-485 can support single-master/multiple-slave or multi-master modes of communication between serveral devices. RS-485 is commonly used on factory floor networks because of the noise immunity and ability to connect multiple devices.



Embedded Systems Firmware Demystified
Embedded Systems Firmware Demystified (With CD-ROM)
ISBN: 1578200997
EAN: 2147483647
Year: 2002
Pages: 118
Authors: Ed Sutter

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net