A primer on extending serial ports in embedded designsEven with the advent to USB, the serial port refuses to die. With the term "serial port" we will usually mean the hardware more or less compliant to the RS-232 standard, or the corresponding TTL signaling.
The serial port is easy to debug in the initial phase of hardware and software integration. Many external devices still connect to the serial port even after advent of USB. Bluetooth modules, GPS modules, medical devices connect to one another by using serial ports for data transmission.
In most of the embedded systems at least two serial ports are provided. However, some systems need more that. So, this requires some way to extend the number of serial ports. Some of the choices available to the designer include USB to serial port, I2C to serial port, Address/Data Bus to Serial Port (UART Controller).
A Serial Port Primer
From the hardware perspective a serial port has at least three pins " a Transmitter, a Receiver and a Ground. Additional pins are used for hardware flow control and may or may not be used. In a typical embedded system only three pins are used and there is no hardware flow control.
The classical Serial port uses a DB9 connector. The Pin out of these 9 pins are shown in Table 1 below.
|Table 1: A Serial Port with DB9 connector|
The typical voltage levels in RS-232 signal level is +12V and "12V. A voltage level of "12V indicates a logic high or 1 and a +12V voltage level indicates a logic zero or 0.
Serial Port in an Embedded System
Almost all embedded systems provide two or more serial port and typically support TTL logic levels. The embedded system may need to interface with two kinds of external devices, one that communicate at TTL level and another that communicates at RS232 levels.
If the device communicates at TTL level, the connection between the embedded system and external device is straight forward. But if the device needs RS232 level signaling, we will have to insert a RS-232 Line Driver/Receiver between the processor and the device.
Most of the today's devices only need three wires Transmit Data, Receive Data and Signal Ground. No hardware flow control is used. This simplifies the hardware connection as well as the software design.
A Typical Embedded System
Figure 1 below shows a typical embedded system using 4 serial ports. Port 1 of the embedded system is used for bootloader and debugging purpose. This port needs a RS232 Line Driver since it will be connected to desktop and/or laptop for debugging purposes. Typically this port may be removed after the initial spin of the board if the PCB board space is a constraint.
Port 2 has been used to communicate with a Bluetooth. Since bluetooth device does not need RS232 level signaling, it has been connected directly to the embedded system.
Port 3 has been used to connect to a GPS (Global Positioning System) device. This device typically does not need RS232 level signaling, and therefore, it has been connected directly to the embedded system.
Port 4 has been used to connect to a general purpose external device. For example, an external RFID scanner. Let us assume that this device needs RS232 level signaling. We will use a RS232 Line Driver between the embedded processor and the RFID scanner.
|Figure 1: A typical Embedded System with 4 serial ports.|
Depending upon the application, an embedded system may need more
than 4 serial ports. Some of these will need TTL Level signaling and
others will need RS232 level signaling.