PERIPHERALS
Peripherals (of a processor) are its means of communicating with the external world.
(1) Peripheral Classification
Peripherals can be classified based on following characteristics
Simplex, Duplex & Semi Duplex
Simplex communication involves unidirectional data transfers. Duplex communication involves bi-directional data transfers. Full Duplex interfaces have independent channels for transmission and reception. Semi-duplex communication involves data bi-directional data transfers, however at a given time, the data transfer is only possible in one direction. Semi-duplex interfaces involves the same communication channel for both transmission and reception.
Serial Vs Parallel
Serial peripherals communicate over a single data line. The data at Tx end needs to be converted “Parallel to Serial” before transmission and the data at Rx end needs to be converted “Serial to Parallel” after reception. Serial peripherals imply less signal lines on the external interface and thus reduced hardware (circuit board) complexity and cost. However the data rate on serial interfaces are fairly limited (as compared to the parallel interface). At the same clock rate, parallel interface can transfer Nx data, as compared to the serial interface (where N is the number of Data lines).
Synchronous Vs Asynchronous
Synchronous transfers are synchronized by a reference clock on the interface. This clock signal is generally provided by one of the devices (who are communicating) on the interface, called master device. However clock can also come from an external source.
Data Throughput
Interfaces can also be classified based on the data throughput they offers. Generally parallel interfaces provide much more data throughput and are used for application data (this data needs to be processed by the application). Serial interfaces offer less data throughputs, and are generally used to transfer intermittent control data.
(2) Common Serial Peripherals
(a) UART (Universal Asynchronous Receiver Transmitter)
UART is one of the oldest and most simple serial interface. Generally UART is used to tranfer data between different PCBs (Printed Circuit Boards). These PCBs can be either in the same system or across differnt systems. In its simplest configuration, UART consists of two pin interface. One pin is used for Transmission, and other for Reception.
The data on UART is transferred word by word. A word consists of Start Bit, Data bits (5 to 8), (and optional parity bit) and (1, 1.5 or 2) Stop Bit. The individual bits of data word are transferred one by one on the serial bus.
Start Bit: The Tx Line of a UART Transitter is high during periods of inactivity (when no communication is taking place). When the transmitter wants to initiate a data transmission it sends one START bit (drives the Tx line low) for one bit duration.
Data Bits: Number of data bits can be configured to any value between 5 and 8. UART employs LSB first Transmission.
Parity Bit: One parity bit can be optionally transitted along with each data word. The parity bit can be configured either as Odd or as even.
Stop Bit: After each word transmission, transmitter transmits Stop bits (drives the Tx line high). Number of stop bits can be configured as 1, 1.5 or 2.
Asynchronous Transmission: UART data transfers are asynchronous. The transmitter transmits each bit (of the word being transmitted) for a fixed duration (defined by baud rate). The receiver polls the value of transmit line (of transmitter). In order to be able to receive the data correctly, receiver needs to be aware of the duration for which each bit is transmitted (it is defined by baud rate).
Baud Rate: Baud is a measurement of transmission speed in asynchronous communication. It is defined as the number of distinct symbol changes made to the transmission media per second. Since UART signal has only two levels (high and low), baud rate here is also equal to the bit rate.
RS-232 and DB-9
UART can be used to transfer data directly across any two devices. However the most common usage of UART involves transfer of data from a PC (or other host computer) to a remote board (other slave device). Under such scenarios (where distance between two devices is more than a few inches), physical interface between Tx and Rx devices is defined by RS-232 specifications. Signals at each end are terminated to a 9-pin (DB-9) connector.
Debugging UART Interface
Following steps could be helpful while debugging communication problems on a UART interface
(a) UART loop-back: Run the internal loop-back tests on both Rx and Tx (most UART devices provide this functionality). This will ensure that each device is functional (not damaged)
(b) Check the Configuration: If the communication between two devices is failing, there could be a configuration mismatch between Tx and Rx. Cross-check the configuration at both sides and ensure that it is identical.
(c) Check the Serial Cable: Generally two UARTs are connected through a serial cable (which has 9-pin connectors on both sides). The cable should be a cross-over (Tx on one side connects to Rx on other side). A faulty (damaged or wrong corssings) serial cable can also cause erratic behavior. Make sure that cable is not damaged.
(d) Probe the Tx signal: If UART communication still remains erratic (after checks a, b and c), the last resort would be to probe the UART signals using a scope.
Limitation: Both the sender and receive should agree to a predefined configuration (Baud Rate, Parity Settings, number of data and stop bits). A mismatch in the configuration at two ends (Transmitter and Receiver), will cause communication failure (data corruption). Data rates are very slow. Also, if there are more devices involved in communication, the number of external pins needed on the device increase proportionally.
No comments:
Post a Comment