(DevCourseWeb - Com) SerialCommunicationProtocolsandStandards
(DevCourseWeb - Com) SerialCommunicationProtocolsandStandards
Serial Communication
Series Editors:
JUNSHAN ZHANG
Arizona State University
USA
Indexing: All books published in this series are submitted to the Web of
Science Book Citation Index (BkCI), to SCOPUS, to CrossRef and to Google
Scholar for evaluation and indexing.
Peter Dawoud
Microsoft
USA
River Publishers
Published, sold and distributed by:
River Publishers
Alsbjergvej 10
9260 Gistrup
Denmark
www.riverpublishers.com
To Dajana
P.D
Contents
Preface xix
1 Serial Communication 1
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Data Communication Standard . . . . . . . . . . . . . . . . 2
1.2.1 Communication Protocol . . . . . . . . . . . . . . 2
1.2.1.1 Types of electronic communication
protocols . . . . . . . . . . . . . . . . . 3
1.2.2 Serial Data Communication Standards . . . . . . . 8
1.3 Serial and Parallel Communications . . . . . . . . . . . . . 9
1.3.1 Serial Communication . . . . . . . . . . . . . . . 9
1.3.2 Parallel Communication . . . . . . . . . . . . . . 11
1.3.2.1 Serial and parallel communication
tradeoffs . . . . . . . . . . . . . . . . . 11
1.3.2.2 Serial versus parallel communication . . 12
1.3.2.3 Major factors limiting parallel
communication . . . . . . . . . . . . . 14
1.3.2.4 Advantages of serial over parallel . . . . 14
1.4 How Are Data Sent Serially? . . . . . . . . . . . . . . . . . 15
1.5 Modes of Serial Transmission . . . . . . . . . . . . . . . . 15
1.5.1 Need for Synchronization . . . . . . . . . . . . . 15
1.5.2 Modes of Transfer: Serial Transmission Modes . . 17
1.5.3 Serial Communication Types . . . . . . . . . . . . 18
vii
viii Contents
10 WiMAX 407
10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . 407
10.2 WiMAX and Other Wireless Technologies . . . . . . . . . 408
10.3 Basics of WiMAX Technology . . . . . . . . . . . . . . . . 409
10.4 WiMAX History . . . . . . . . . . . . . . . . . . . . . . . 411
10.5 WiMAX Versions . . . . . . . . . . . . . . . . . . . . . . . 412
10.6 Benefits of Using WiMAX . . . . . . . . . . . . . . . . . . 413
Contents xvii
Index 487
xix
xx Preface
Some of the protocols that have been developed based on serial commu-
nication in the past few decades are:
1. SPI – Serial Peripheral Interface
2. eSPI Protocol
3. I2C – Inter-Integrated Circuit
4. I3C
5. CAN
6. FireWire
7. Ethernet
8. Universal Serial Bus (USB)
9. Microwire
10. 1-Wire
11. UART and USART
We can add to the above protocols the following:
12. Bluetooth
13. ZigBee
14. Z-Wave
15. Wi-Fi
16. WiMAX
17. INSTEON
The protocols can be divided widely into two groups: inter system pro-
tocols (e.g., UART Protocol, USART Protocol, and USB Protocol) and intra
system protocols (e.g., I2C, I3C, CAN, and SPI) which can be used to build
networks.
Serial communication, synchronous or asynchronous, is typically imple-
mented with a recommended standard (RS). The standard usually defines
signal levels, maximum bandwidth, connector pinout, supported handshaking
signals, drive capabilities, and electrical characteristics of the serial lines.
Nowadays and in most cases, the standard is set by the Electronic
Industries Association (EIA). The RS-232 and its variant are currently in use.
The main goal of the authors of this document is to give the reader
enough knowledge about the above-mentioned protocols and standards. To
achieve this target, the authors divided the document into two books: “Serial
Communication Protocols and Standards” and “Microcontroller and Smart
Home Networks.”
Preface xxi
xxiii
xxiv List of Figures
xxxi
xxxii List of Tables
xxxv
xxxvi List of Abbreviations
1.1 Introduction
Serial Data Communication
Data communication is one of the most challenging fields today as far as
technology development is concerned. Data, essentially meaning information
coded in digital form, that is, 0s and 1s, need to be sent from one point to the
other either directly or through a network.
When many such systems need to share the same information or different
information through the same medium, there arises a need for proper organi-
zation (rather, “socialization”) of the whole network of the systems, so that
the whole system works in a cohesive fashion.
Therefore, in order for a proper interaction between the data transmitter
(the device that commences data communication) and the data receiver (the
system that receives the data sent by a transmitter), there has to be some set
of rules or “protocols” which all the interested parties must obey.
The requirement above finally paves the way for some DATA COMMU-
NICATION STANDARDS. In general, communication standards incorporate
both the software and hardware aspects of the system, while buses mainly
define the cable characteristics for the same communication type. The stan-
dards define the communication capabilities of the data communication
systems so that the systems are not vendor specific but for each system the
user has the advantage of selecting the device and interface according to his
own choice of make and range.
Depending on the requirement of applications, one has to choose the
type of communication strategy. There are basically two major classifications,
namely SERIAL and PARALLEL, each with its variants. Serial communi-
cation is the process of sending data one bit at a time, sequentially, over a
communication channel or computer bus. This contrasts with parallel com-
munication, where several bits are simultaneously sent on a link with several
1
2 Serial Communication
labeled as Rx and Tx. On the transmitting end, the UART takes bytes of data
and send the individual bits in a sequential manner. The vice versa takes place
on the receiving end. Figure 1.3 shows the UART protocol data flow.
The UART is a half-duplex protocol, transmitting and receiving the data
but not at the same time, for example, Emails, SMS, and Walkie-talkie.
USART (Universal Synchronous/Asynchronous Receiver and Transmit-
ter): It is a serial communication with a two-wire protocol. The data cable
signal lines are labeled as Rx and Tx. This protocol is used for transmitting
and receiving the data byte by byte along with the clock pulses. It is a full-
duplex protocol, transmitting and receiving simultaneously with different
baud rates. Different devices communicate with microcontroller using this
protocol. Figure 1.4 shows USART protocol data flow.
USB (Universal Serial Bus): It is, as UART and USART, a serial commu-
nication with a two-wire protocol. The data cable signal lines are labeled
as “D+” and “D−.” USB protocol is used to communicate with the system
peripherals. The protocol is used to send and receive the data serially to the
host and peripheral devices. Communication using USB requires a driver
1.2 Data Communication Standard 5
software that is based on the functionality of the system. USB device can
transfer data on the bus without any request on the host computer (Figure 1.5).
Examples of USB are Mouse, Keyboard, Hubs, Switches, and pen drive.
the message and the meaning of each part of the message. This takes place
by the hardware of the device. To connect any device to the bus, an external
device must be used as an interface which will be responsible for putting the
message in a form fulfilling all the electrical specifications of the port. For
example, if the message is in the form of 0s and 1s, then it is the responsibility
of the external interface to represent the binary 1 and binary 0 by certain well-
defined voltage, for example, binary 1 by −12 V and binary 0 by +12 V. The
most famous serial communication standard is RS-232.
The above-mentioned communication protocols and also RS-232 and its
deferent versions will be considered in detail in the chapters of this book.
This book introduces to the reader enough knowledge that will let him/her to
understand all the above-mentioned protocols and that will enable him/her to
design applications that needed the use of any one of these protocols.
10110001 Receiver
Transmier
Serial Transfer
are for overhead control signaling and not data transmission; the two data
wires perform simple serial transmission in either direction. In this case,
a computer may not be close to a modem, making the cost of parallel
transmission prohibitive—thus, the speed of transmission may be considered
less important than the economical advantage of serial transmission.
the type of media used and the amount of external interference present, RS-
232 can be transmitted at higher speeds, or over greater distances, or both.
Parallel transmission has similar distance-versus-speed tradeoffs, as well as a
clocking threshold distance. Techniques to increase the performance of serial
and parallel transmission (longer distance for same speed or higher speed for
same distance) include using better transmission media, such as fiber optics
or conditioned cables; implementing repeaters; or using shielded/multiple
wires for noise immunity.
150, 300, 600, 900, 1200, 2400, 4800, 9600,13.8 k,14.4 k,19.2 k, 38.4
k, and 57.8 k.
2. Clock skew: In a parallel circuit, clock skew is the time difference in
the arrival of two sequentially adjacent registers. Figure 1.14 shows the
meaning of “clock skew.” The 8 bits are leaving the transmitter exactly
at the same instant; during propagation on the communication channel,
there is bound to be a time difference in the arrival of the eight bits to the
receiver: there is difference between the arrival of the first bit and that of
the second bit, and so on. This time difference is what is called “clock
skew.”
Figure 1.14 illustrates this: There is a time lag in the data bits through
different channels of the same bus. Clock skew is inevitable due to
differences in physical conditions of the channels, like temperature,
resistance, path length, etc.
3. Crosstalk: It is a phenomenon by which a signal transmitted on one
channel of a transmission bus (or circuit) creates an undesired effect in
another channel (or circuit). Crosstalk is usually caused by undesired
capacitive, inductive, or conductive coupling from one circuit, part of a
circuit, or channel, to another. It can be seen from the following diagram
that clock skew and crosstalk are inevitable.
14 Serial Communication
transmits an 8-bit word, the receiver will interpret it as a 9-bit word. This is
shown in Figure 1.16.
From Figure 1.16, it is clear that this difference in the speed of the clocks
will not only increase the number of the received bits but also sample wrong
bits. The conclusion should be that there can be no unambiguous interpreta-
tion of a common signal, if there is not a certain degree of synchronization of
clocks.
Another well-known problem of time dispersion is called intersymbol
interference.
Signals belonging to different symbols can be observed on the medium at
the same time, leading to interpretation errors at the receiver’s end.
Synchronization techniques will guide the receiving system in determin-
ing where data entities start and end and at which time interval the sampling
result is least error prone.
It is possible to look to the bit and frame synchronization as a very basic
mechanism of error control which will reduce the need for error control at
higher levels.
Two approaches exist to solve the problem of synchronization: asyn-
chronous transmission and synchronous transmission.
Each of the serial protocols that have been developed over the years as
Universal Serial BUS (USB), Ethernet, SPI, I2C, and the serial standard,
which will be considered in this book, can be sorted into one of these two
modes: synchronous mode or asynchronous mode.
What is needed to decode the received signal? The receiver will have
to determine where a signal cell (representing a bit) starts and ends in order
to sample the signal as near at the middle of the signal as possible. It will
have to know where a character or a byte starts or ends and, for packet-based
transmission, where each message block starts or ends.
This makes for a more straightforward, often faster serial transfer, but
it also requires at least one extra wire between communicating devices.
Examples of synchronous interfaces include SPI and I2C.
– Bit-synchronization is also a technique of synchronization in
which during data transmission, sender and receiver should be
synchronized at the bit level.
• Asynchronous means that data are transferred without support from
an external clock signal. This transmission method is perfect for mini-
mizing the required wires and I/O pins, but it does mean we need to put
some extra effort into reliably transferring and receiving data. UART is
the most common form of asynchronous transfer.
Asynchronous interface relies on four parameters, namely:
1. Baud rate control
2. Data flow control
3. Transmission and reception control
4. Error control.
This transmission method is perfect for minimizing the required wires
and I/O pins, but it does mean we need to put some extra effort into reliably
transferring and receiving data.
This chapter introduces the most common serial protocols of asyn-
chronous transfer.
Asynchronous protocols are suitable for stable communication. These are
used for long distance applications. UART is an example of asynchronous
serial protocol, and examples of serial interface standards are RS-232, RS-
422, and RS-485.
The next section introduces the topic of serial communication types,
and the three sections after that discusses the three modes of operation:
asynchronous data transfer, synchronous data transfer, and bit-synchronous
operation.
• Half-duplex is when data can be sent or received, but not at the same
time. This means that data transmission can occur in only one direction
at a time, that is, either from the master to the slave, or from the slave to
the master, but not both.
• The protocol assumes that both the transmitter and the receiver are
configured in the same way, that is, follow the same definitions for the
start, stop, and the actual data bits.
• Both devices, namely the transmitter and the receiver, need to commu-
nicate at an agreed upon data rate (baud rate) such as 19.200 Kb/s or
115.200 Kb/s.
The asynchronous protocol is usually as follows:
• The first bit is always the START bit (which signifies the start of
communication on the serial line), followed by DATA bits (usually 8-
bits), followed by a STOP bit (which signals the end of data packet).
There may be a Parity bit just before the STOP bit. The Parity bit was
earlier used for error checking, but is seldom used these days.
• The START bit is always low (0), while the STOP bit is always high (1).
Figure 1.9 explains it.
• Data bits are a measurement of the actual data bits in a transmission.
When the computer sends a frame of information, the amount of actual
data may not be a full 8 bits. Asynchronous systems allow a number of
variations including the number of bits in a character. It allows standard
1.6 Asynchronous Data Transfer 21
values for frames as 5, 7, and 8 bits. Which setting you choose depends
on what information you are transferring. For example, standard ASCII
has values from 0 to 127 (7 bits). Extended ASCII uses 0 to 255 (8 bits).
If the data you are transferring is standard ASCII, sending 7 bits of data
per frame is sufficient for communication. A frame refers to a single
byte transfer, including start/stop bits, data bits, and parity. Because the
number of actual bits depends on the protocol selected, you can use the
term “frame” to cover all instances.
• Stop bits are used to signal the end of communication for a single frame.
Typical values are 1, 1.5, and 2 bits. Because the data are clocked across
the lines and each device has its own clock, it is possible for the two
devices to become slightly out of sync. Therefore, the stop bits not only
indicate the end of transmission but also give the computers some room
for error in the clock speeds. The more bits used for stop bits, the greater
the lenience in synchronizing the different clocks, but the slower the data
transmission rate.
• Parity is a simple form of error checking used in serial communication.
There are four types of parity: even, odd, marked, and spaced. You can
also use no parity. For even parity and odd parity, the serial port sets the
parity bit (the last bit after the data bits) to a value to ensure that the
transmission has an even or odd number of logic-high bits. For example,
if the data value is 011, for even parity, the parity bit is 0 to keep the
number of logic-high bits even. If the parity is odd, the parity bit is 1,
resulting in 3 logic-high bits. Marked parity and spaced parity do not
actually check the data bits but simply set the parity bit high for marked
parity or low for spaced parity. This allows the receiving device to know
the state of a bit so the device can determine if noise is corrupting the
data or if the transmitting and receiving device clocks are out of sync.
Today, the most common standard has 8-bit characters, with 1 stop bit
and no parity and this is frequently abbreviated as “8-1-n.” A single 8-bit
character, therefore, consists of 10 bits on the line, that is, One Start bit,
Eight Data bits and One Stop bit (as shown in Figure 1.19).
For NRZ encoding, see latter, where line idle is encoded with 1, the start
bit has the value 0 and the stop bit thus has the value 1. This variant, “8-
1-n”, of encoding adds at least 25% overhead to every byte transmitted, but
that does not matter because asynchronous transmission is used mostly for
peripheral devices such as keyboards or devices connected to the serial port
of the computer.
22 Serial Communication
Figure 1.19 Serial data line to transmit character “K” in asynchronous mode.
the leading or trailing edges of the transmission on the data line are distorted
in transmission. It then samples the parity bit and stop bits.
The actual information, which the transmitter is sending to the receiver, is
contained in the data bits. The data bits of each transmitted word are formed
by the START and STOP bits. The receiver uses these framing bits as a means
for determining which bits are the data bits.
The subject of frame synchronization and data sampling points will be
discussed again in Chapter 2.
popularized these days to fill the gap for high-speed, relatively short-run,
heavy-data-handling applications, but still, the above four satisfy the needs of
all those high-speed and longer run applications found most often in industrial
settings for plant-wide security and equipment networking.
RS-232, RS-423, RS-422, and RS-485 specify the communication system
characteristics of the hardware such as voltage levels, terminating resistances,
and cable lengths. The standards, however, say nothing about the software
protocol or how data are framed, addressed, checked for errors, or interpreted.
Figure 1.21 RTZ coding: The binary signal is encoded using rectangular pulse amplitude
modulation with polar return-to-zero code.
Figure 1.24 NRZ coding: The binary signal is encoded using rectangular pulse–amplitude
modulation with polar NRZ(L) or polar non-return-to-zero-level code.
Figure 1.25 Encoding with NRZ: Non-return-to-zero encoding for amplitude shift
modulation.
For certain protocols, where long sequences of zeros or ones are transmitted,
there will be long sequences without any change in signal. As the receiver’s
clock has no way to synchronize, it will run out of sync, and sampling of
the incoming signal will lead to wrong results because the receiver fails to
identify the bit boundaries.
Non-return-to-zero encoding and its derivatives should be used only when
it can be guaranteed that the higher level protocols will not result in long
sequences of identical bits. This behavior can be guaranteed for asynchronous
transmission with start and stop bits, but not for synchronous transmission.
This limitation can be overcome by using the Manchester encoding,
which we will cover in the next section.
helps in the character synchronization: once the receiver receives the start bit,
it starts character assembly.
Bit duration in synchronous communications is not necessarily predefined
at both the transmitting and receiving ends. Typically, a clock signal is
provided in addition to the data signal. This clock signal will mark the
beginning of a bit cell on a predefined transmission. The source of the clock
is predetermined, and sometimes multiple clock signals are available. For
example, if two nodes want to establish synchronous communications, point
A could supply a clock to point B that would define all bit boundaries that
A transmitted to B. Point B could also supply a clock to point A that would
correspond to the data that A received from B. This example demonstrates
how communications could take place between two nodes at completely
different data rates.
into a valid character. The following 8 bits are also assembled into a character.
This assembly will repeat until another predefined sequence of bits is received
(either another sync flag or a bit combination that signals the end of the text,
i.e., EOT). The actual sync flag and protocol varies depending on the sync
format (SDLC, BISYNC, etc.).
In some more detail, in case of synchronous transmission, at the beginning
of data transmission, only synchronizing characters are transmitted and only
after that the actual data transmission begins. Therefore, to synchronize the
transmitter with the starting of a character, the receiver operates in a hunt
mode. Initially, all the bits of the data received are set “1.” Then, the data line
is sampled and the received bit is put on MSB shifting rest of the bits toward
right. The data so formed are compared with the synchronizing character.
If the data are different than the synchronizing character, the data line is
again sampled and new data are formed and compared with the synchronizing
character. In this way, the receiver operated in hunt mode—making bit by bit
comparison of the input stream with the value of the synchronizing character
until it detects the synchronizing character. Once the desired character is
detected, the receiver treats each subsequent group of n-bits as a character.
The transmitter continues to send synchronizing characters to maintain the
synchronization, even if the sources of data character do not have data
ready for transmission. In this case, the transmitter sends the synchronizing
character continuously, and thus, the time interval between two characters is
fixed. The clocks in the transmitter and receiver operate at exactly the same
frequency and must be very stable to maintain synchronization for a long
period of time. Typically, thousands of blocks if character can be sent without
re-synchronizing the receiver.
timing signal can be used by the receiver to synchronize with the transmitter
using a Digital Phase-Locked Loop (DPLL) (Figure 1.28).
Figure 1.31 shows the encoding of the same bits as those in Figure 1.30.
The differential Manchester encoding variant is used for token ring networks.
Table 1.4 summarizes the differential Manchester encoding scheme.
Figure 1.32 Bipolar clock encoding [From [halsall95], page 104, Figure 3.8].
the local clock to the encoded signal of the bit stream resulting in a bipolar
encoded signal which the receiver will have to interpret. By using this bipolar
encoding, it is not necessary to create an additional transmission line just for
the clock signal.
Each bit span of the bipolar signal is dived in the middle by the signal
shift of the clock. There are two possible values for each bit span: high-zero
and low-zero, denoting logical one and logical zero. The received signal will
contain enough information for the encoder as it can determine the length of a
bit by the guaranteed signal change at the end of each bit, and it can determine
the literal value by distinguishing between a positive or negative signal in the
first half of the bit time.
A good example that describes bipolar clock encoding is given in
Figure 1.32.
As can be seen in Figure 1.32, “bipolar clock encoding” signal of the
transmitter clock is added to the bit stream that should be transmitted; the
resulting signal is bipolar and contains a clock signal that can be extracted in
order to encoding the bit stream.
This way of clock encoding is also a return-to-zero encoding, as it requires
a medium capable of carrying bipolar encoded signals. This limitation can be
overcome by using a digital phase-locked loop (DPLL).
Figure 1.34 Manchester encoding for encoding a clock signal [From [halsall95], page 104,
Figure 3.8].
one time unit and being late for another will sum up to nothing. The clocks
are in synchronism again.
A digital phase-locked loop will work with non-return-to-zero encodings
as well as with non-return-to-zero inverted (NRZI) encodings like Manch-
ester code or the differential Manchester code, but NRZI encodings require a
higher signaling rate for the same bit rate and are therefore used especially in
LANs.
bus, although this must be reviewed on a per-device basis. Both SPI and
Microwire are generally limited to on-board communications and traces
of no longer than 6 inches, although longer distances (up to 10 ft) can be
achieved given proper capacitance and lower bit rates.
9. 1-Wire: Dallas Semiconductor’s 1-Wire bus is an asynchronous, mas-
ter/slave bus with no protocol for multi-master. Like the I2 C bus, 1-Wire
is half-duplex, using an open-drain topology on a single wire for bidirec-
tional data transfer. However, the 1-Wire bus also allows the data wire to
transfer power to the slave devices, although this is somewhat limited.
Although limited to a maximum speed of 16 Kbps, bus length can be
upwards of 1,000 ft, given the proper pull-up resistor.
10. UART and USART: UART stands for Universal Asynchronous
Receiver Transmitter, whereas USART stands for Universal Synchronous
Asynchronous Receiver Transmitter. They are basically just a piece
of computer hardware that converts parallel data into serial data. The
only difference between them is that UART supports only asynchronous
mode, whereas USART supports both asynchronous and synchronous
modes. Unlike Ethernet, Firewire, etc., there is no specific port for
UART/USART. They are commonly used in conjugation with protocols
like RS-232, RS-434, etc. (we have specific ports for these two!).
In synchronous transmission, the clock data are recovered separately
from the data stream and no start/stop bits are used. This improves the
efficiency of transmission on suitable channels since more of the bits
sent are usable data and not character framing.
The USART has the following components:
• A clock generator, usually a multiple of the bit rate to allow
sampling in the middle of a bit period
• Input and output shift registers
• Transmit/receive control
• Read/write control logic
• Transmit/receive buffers (optional)
• Parallel data bus buffer (optional)
• First-in, first-out (FIFO) buffer memory (optional)
11. RS-232 (Recommended Standard 232): The RS-232 is typically con-
nected using a DB9 connector, which has 9 pins, out of which 5 are
input, 3 are output, and one is ground. You can still find this so-called
serial port in some old PCs. In our upcoming posts, we will discuss
mainly about RS-232 and USART of AVR microcontrollers.
1.11 Electrical Interface Standards 41
References
[1] “Interface Between Data Terminal Equipment and Data Circuit-
Terminating Equipment Employing Serial Binary Data Interchange,”
TIA/EIA-232-F Standards, Electronics Industries Association Engineer-
ing Department.
[2] “Electrical Characteristics of Balanced Digital Interface Circuits,”
TIA/EIA-422-B Standards, Electronics Industries Association Engineer-
ing Department.
[3] “Standard for Electrical Characteristics of Generators and Receivers
for Use in Balanced Digital Multipoint Systems,” TIA/EIA-485-A
Standards, Electronics Industries Association Engineering Department.
[4] “The I2 C Specification,” Version 2.1, Philips Semiconductors.
[5] Aleaf, Abdul, “Microwire Serial Interface,” Application Note AN-452,
National Semiconductor.
References 45
2.1 Introduction
The Universal Asynchronous Receiver/Transmitter (UART) controller is the
key component of the serial communication subsystem of a microprocessor,
microcontroller, and computer. It is a computer hardware device for asyn-
chronous serial communication in which the data format and transmission
speeds are configurable.
The UART device changes incoming parallel data to serial data which
can be sent on a communication line. A second UART is used to receive the
information which converts serial data to parallel. The UART performs all
the tasks, timing, parity checking, etc. needed for the communication. UART
does not generate the external signaling levels that are used between different
equipment. An interface, external line drive, is used to convert the logic level
signals of the UART to the external signaling levels. Examples of standards
for voltage signaling are RS-232, RS-422, and RS-485 from the EIA. For
embedded system applications, UARTs are commonly used with RS-232. It
is useful to communicate between microcontrollers and with PCs. MAX 232
is one of the example ICs which provide RS-232 level signals. Besides the
EIA RS standards, there is also a CCITT standard named V.24 that resembles
the specifications included in RS-232-C.
The UART structure contains several registers that are accessible to set
or review the communication parameters that facilitate the use of UART
in different environments. Using these registers, the communication speed
(baud rate), the type of parity check, and the way incoming information is
signaled to the running software are set according to the requirement of host
processor.
47
48 Universal Asynchronous Receiver/Transmitter (UART)
The most common UART used is 16550A. Newer versions such as 16650
contain two 32-byte FIFO buffers, and on-board support for software flow
control is the latest advancement in industry. Texas Instruments is developing
the 16750 UART which contains 64-byte FIFO buffers.
These two types of cables, as shown in Chapter 3, differ in how the wires
are connected to the connector. Each wire represents a signal, and each
signal has a function. A standard serial cable passes all of the RS-232C
signals straight through. For example, the “Transmitted Data” pin on the
one end of the cable goes to the “Transmitted Data” pin on the other end.
This is the type of cable used to connect a modem to a computer and is
also appropriate for some terminals.
A null-modem cable switches the “Transmitted Data” pin of the connec-
tor on the one end with the “Received Data” pin on the other end. The
connector can be either a DB-25 or a DB-9.
Straight cables and null-modem cables are given in detail in Chapter 3.
or byte) that is to be transmitted. The Start Bit indicates the start of the data
transmission and it alerts the receiver that a word of data is about to be sent.
Upon reception of start bit, the clock in the receiver goes into synchronization
with the clock in the transmitter. The accuracy of these two clocks should not
deviate more than 10% during the transmission of the remaining bits in the
word.
The individual bits of the word of data are sent after the start bit. Least
significant bit (LSB) is sent first. The transmitter does not know when the
receiver has read at the value of the bit. The transmitter begins transmitting
the next bit of the word on next clock edge. This continued till the transmitter
completes transmitting the data bits. In Figure 2.1, the data consist of 8 bits
(D0–D7), but it could be 5, 6, or 7 bits long.
Parity bit, which is an optional bit, is to be added when the entire data
word has been sent. This bit can be used to detect errors at the receiver side.
Then, one Stop Bit is sent by the transmitter to indicate the end of the valid
data bits. Some protocols allow 1.5 or 2 STOP bits.
The UART transmitter and receiver must agree, before starting commu-
nication, upon the number of data bits per frame, if there is one or no parity
bit and the number of stop bits. Line control register (LCR) is used for this
purpose. Based on the settings chosen in the LCR, the UART transmitter
sends the start bit, 5, 6, 7, or 8 data bits, one or no parity bit and 1, 1.5, or 2
stop bits.
The UART transmitter section, as given in Section 2.5.1, includes a
transmitter hold register (THR) and a transmitter shift register (TSR). Modern
UART devices include transmit and receive FIFO buffers. When the UART
is in the FIFO mode, THR is a 16-byte FIFO. Line control register (LCR) is
controlling the transmission section.
The UART receiver section includes a receiver shift register (RSR) and
a receiver buffer register (RBR). When the UART is in the FIFO mode,
RBR is a 16-byte FIFO. Receiver section control is a function of the
UART line control register (LCR). Based on the settings chosen in LCR,
the UART receiver accepts the following from the transmitting device: 1
START bit; 5, 6, 7, or 8 data bits; 1 PARITY bit, if parity is selected; and
1 STOP bit
Once the receiver section receives all of the bits in the data word, it can,
based on the contents of LCR, check for the parity bits. (The contents of
LCR reflect the agreement between the transmitter and the receiver about
the parity bit, if it is used or not). Then, stop bit is encountered by receiver.
A missing stop bit may result entire data to be garbage. This will cause a
2.4 UART Timing: Serial Data Format and Asynchronous Serial Transmission 53
framing error and will be reported to the host processor when the data word
is read. Framing error can be caused due to mismatch of transmitter and
receiver clocks.
The UART automatically discards the Start, Parity and Stop bits irrespec-
tive of whether data is received correctly or not. If the sender and receiver are
configured identically, these bits are not passed to the host. To transmit new
word, the Start Bit for the new word is sent as soon as the Stop Bit for the
previous word has been sent.
The transmission speed in asynchronous communication is measured by
baud rate. A baud rate represents the number of bits that are actually being
sent over the media. The baud rate includes the start, stop, and parity bits.
The bit rate (bits per second, bps) represents the amount of data that are
actually sent from the transmitting device to the other device. Speeds for
UARTs are in bits per second (bit/s or bps), although often incorrectly called
the baud rate. Standard baud rates are as follows: 110, 300, 1200, 2400, 4800,
9600, 14400, 19200, 28800, 38400, 57600, 76800, 115200, 230400, 460800,
921600, 1382400, 1843200, and 2764800 bit/s.
Figure 2.2 UART receive frame synchronization and data sampling points.
synchronize itself and therefore determine the best data-sampling point for
the bit stream.
Figure 2.2 shows a common method used by a UART receiver to syn-
chronize itself to a received frame. The receive UART uses a clock that is
16 times the data rate. A new frame is recognized by the falling edge at
the beginning of the active-low START bit. This occurs when the signal
changes from the active-high STOP bit or bus idle condition. The receive
UART resets its counters on this falling edge, expects the mid-START bit to
occur after 8 clock cycles, and anticipates the midpoint of each subsequent
bit to appear every 16 clock cycles thereafter. The START bit is typically
sampled at the middle of bit time to check that the level is still low and ensure
that the detected falling edge was a START bit, not a noise spike. Another
improvement is to sample the START bit three times (clock counts 7, 8, and
9, out of 16) instead of sampling it only at the midbit position (clock count 8
out of 16). The UART of most of the microcontrollers is using this technique.
Sometimes, the UART uses sampling rate which is 13 times (13x) the
baud rate. In such cases, the sampling takes place on the 6th cycle.
Figure 2.4 UART “nasty link” is sampled reliably within 50% of bit time.
Figure 2.5 UART “normal link” is sampled reliably within 75% of bit time.
From Figures 2.4 and 2.5, it is possible to determine that the error budget
is ±25% and ±37.5% from the optimal bit-center sampling point for the
nasty and normal scenarios, respectively. This error is equivalent to ±4 or
±6 periods of the 16x UART receive clock. Another error to include in this
budget is the synchronization error when the falling edge of the START bit is
detected. The UART will most likely start on the next rising edge of its 16x
clock after detecting the START bit. Since the 16x clock and the received
data stream are asynchronous, the falling edge of the START bit could occur
just after a 16x clock rising edge. The falling edge could, alternatively, occur
just before the clock rising edge, but not with enough setup time to use it.
This means that the UART has a ±1 bit error built in at the synchronization
point. So our error budget reduces from ±4 or ±6 clock periods to ±3 or ±5
periods.
The above analysis presumed that short-term clock errors (essentially
jitter) are very small, and therefore, we are only considering midterm and
long-term errors. These errors point to a mismatch in the transmit UART and
receive UART timing that is consistent during a frame. Since the timing is
synchronized at the falling edge of the START bit, the worst-case timing error
will be at the last data sampling point, which is the STOP bit. The optimum
sampling point for the STOP bit is its bit center, which is calculated as:
(16 internal clock cycles per bit) × (1 start bit + 8 data bits + 1/2 a stop bit)
2.5 UART Functional Block Diagram 57
= (16) × (9.5)
= 152 UART receive clocks after the original falling edge of the
START bit.
logic circuits. Modern UART contains FIFO memories and DMA controller
as part of the two sections. The two sections are commonly provided by
a programmable baud-rate generator, clock generator. This generator can
divide the UART input clock by divisor from 1 to 65535 producing a 16×
reference clock or a 13× reference clock for the internal transmitter and
receiver logic. The baud-rate generator is used for generating the speed when
the transmitter section and receiver section have to transmit or receive the
data. The speed ranges from 110 bps to 230400 bps. Typically, the baud rates
of microcontrollers are 9600 to 115200.
To let the discussion useful, this section introduces the structure of a mod-
ern UART that has FIFO buffer memories and DMA controller. The registers
and other control circuits in such modern UART cover those included in the
structure of any UART device with less capabilities. Modern UART usually
contains the following components:
• A clock generator, usually a multiple of the bit rate to allow sampling in
the middle of a bit period.
• Input and output shift registers
• Transmit/receive control
• Read/write control logic
• Transmit/receive buffers (optional)
• System data bus buffer (optional)
• First-in, first-out (FIFO) buffer memory (optional)
• Signals needed by a third party DMA controller (optional)
• Integrated bus mastering DMA controller (optional)
Figure 2.7 gives the structure of 16550A, which is the most common
UART and has all the capabilities except DMA.
2.5 UART Functional Block Diagram 59
conceptual clock generation diagram for the UART. The processor clock
generator receives a signal from an external clock source and produces a
UART input clock with a programmed frequency. The programmable baud
generator takes the input clock and divides it by a divisor in the range
between 1 and (216 − 1) to produce a baud clock (BCLK). The frequency
of BCLK is 16 times (16×) the baud rate (each received or transmitted bit
lasts 16 BCLK cycles). Sometimes, BLCK is selected to be 13 times (13×)
the baud rate (each received or transmitted bit lasts 13 BCLK cycles). When
the UART is receiving, the bit is sampled, as mentioned before, in the 8th
BCLK cycle for 16× over sampling mode and on the 6th BCLK cycle for
13× oversampling mode. The 16× or 13× reference clock is selected by
configuring the OSM_SEL bit in the mode definition register (MDR). The
formula to calculate the divisor is:
Divisor = (UART Input Clock Frequency)/(Desired Baud Rate x16)
[MDR.OSM_SEL = 0]
Divisor = (UART Input Clock Frequency )/(Desired Baud Rate x13)
[MDR.OSM_SEL = 1]
Two 8-bit register fields (DLH and DLL), called divisor latches, hold this
16-bit divisor. DLH holds the most significant bits of the divisor, and DLL
holds the least significant bits of the divisor. These register fields will be
discussed in detail while discussing UART registers (Section 2.4.2). These
divisor latches must be loaded during the initialization of the UART to ensure
desired operation of the baud generator. Writing to the divisor latches results
in two wait states being inserted during the write access while the baud
generator is loaded with the new value.
Figure 2.9, which is an extended form of Figure 2.3, shows the relation-
ships between data bit, BCLK and UART input clock.
n UART input clock cycles, where n = divisor in DLH:DLL
2.5 UART Functional Block Diagram 61
Figure 2.9 Relationships between data bit, BCLK and UART input clock.
Table 2.1 Baud rate examples for 150-MHz UART input clock and 16× oversampling mode
Baud Rate Divisor Value Actual Baud Rate Error (%)
2400 3906 2400.154 0.01
4800 1953 4800.372 0.01
9600 977 9595.701 –0.04
19200 488 19211.066 0.06
38400 244 38422.131 0.06
56000 167 56137.725 0.25
128000 73 129807.7 0.33
3000000 3 3125000 4.00
Example baud rates and divisor values relative to a 150-MHz UART input
clock and 16× oversampling mode are shown in Table 2.1.
including the 16650 which contains two 32-byte FIFO buffers and on-board
support for software flow control. Texas Instruments is developing the 16750
which contains 64-byte FIFO buffers. It has the following registers:
1. RBR: “Receiver Buffer Register,” or “Receiver Data Register (RDR)
2. THR: “Transmitter Holding Register” or “Transmit Data Register (TDR)
3. IER: “Interrupt Enable Register”
4. IIR: “Interrupt Identification Register”
5. FCR: “FIFO Control Register”
6. LCR: “Line Control Register”
7. MCR: “Modem Control Register”
8. LSR: “Line Status Register”
9. MSR: “Modem Status Register”
10. SCR: “Scratch Pad Register”
11. DLL and DLH: “Divisor Latches”
12. REVID1 and REVID2: “Revision Identification Registers”
13. PWREMU_MGMT: “Power and Emulation Management Register”
14. MDR: “Mode Definition Register”
Eight I/O bytes are used for each UART to access its registers. The
following table shows where each register can be found. The base address
used in the table is the lowest I/O port number assigned. The switch bit DLAB
can be found in the line control register as bit 7 at I/O address base + 3.
Tables 2.2 and 2.3 give the location of each register and UART register to
port conversion.
Before introducing the different registers, it is important to note that the
register’s names mentioned above are used by Texas Instrument and they are
the most common names. Some microcontrollers and other UART devices
may use other names. For example, the “Receiver Buffer Register” is called
“Receiver Data Register” in some cases. The same comment is valid when we
consider the names of the bits of the registers. The important matter here is the
function of each register and each bit. The reader must consult the scientific
manual of the UART device he is using to find the correspondences between
the names.
FIFO buffers. If FIFO buffering is used, each new read action of the register
will return the next byte, until no more bytes are present. Bit 0 in the Line
Status Register (LSR) can be used to check if all received bytes have been
read. This bit will change to zero if no more bytes are present.
The RSR receives serial data from the UARTn_RXD pin. Then, the RSR
concatenates the data and moves them into the RBR (or the receiver FIFO).
In the non-FIFO mode, when a character is placed in RBR and the receiver
data-ready interrupt is enabled (DR = 1 in the IER), an interrupt is generated.
This interrupt is cleared when the character is read from the RBR. In the FIFO
mode, the interrupt is generated when the FIFO is filled to the trigger level
selected in the FIFO control register (FCR), and it is cleared when the FIFO
contents drop below the trigger level.
64 Universal Asynchronous Receiver/Transmitter (UART)
idle, the UART then moves the data from the THR to the TSR. The UART
serializes the data in the TSR and transmits the data on the TX pin. Without
FIFO buffering, only one character can be stored. Otherwise, the amount
of characters depends on the type of UART. To check if new information
must be written to THR, bit 5 in the Line Status Register (LSR) can be
used. Empty register is indicated by value 1. If FIFO buffering is used,
the THR is a 16-byte FIFO and more than one character can be written to
the transmitter holding register when the FIFO is empty. In this mode, the
interrupt is generated when the transmitter FIFO is empty, and it is cleared
when at least one byte is loaded into the FIFO.
THR access consideration:
• The RBR, THR, and DLL share one address. To load the THR, write 0 to
the DLAB bit of the LCR and write to the shared address. When DLAB
= 0, reading from the shared address gives the content of the RBR. When
DLAB = 1, all accesses at the address read or modify the DLL.
• The DLL also has a dedicated address. If the dedicated address is used,
DLAB can = 0, so that the RBR and the THR are always selected at the
shared address.
Legend: R = Read only; W = Write only; W1C = Write 1 to clear (writing 0 has no effect);
−n = value after reset.
• Always write 1 to the DMAMODE1 bit. After a hardware reset, change the
DMAMODE1 bit from 0 to 1. DMAMODE = 1 is required for proper communication
between the UART and the DMA controller.
Figure 2.12 FCR register.
15 8 7 6 5 4 3 2 1 0
Reserved DLAB BC SP EPS PEN STB WLS
R=0 R/W-0 R/W- R/W- R/W- R/W- R/W- R/W- R/W-
0 0 0 0 0 0 0
1–0 WLS 0–3h Word length select. Number of bits in each transmitted or received
serial character. When STB = 1, the WLS bit determines the
number of STOP bits.
00 = 5 bits
01 = 6 bits
10 = 7 bits
11 = 8 bits
31 16
Reserved
R=0
15 6 5 4 3 2 1 0
AFE1 Loop OUT2 OUT1 RTS1 Reserved
R-0 R/W-0 R/W - 0 R/W-0 R/W -0 R/W -0 R -0
Legend: R = Read only; R/W = Read/Write; −n = value after reset.
1. All UARTs do not support this feature. See the device-specific data manual for
supported features. If this feature is not available, this bit is reserved and should be
cleared to 0.
Figure 2.14 Modem control register (MCR).
through 4 record the error conditions that produce a receiver line status
interrupt.
The LSR is shown in Figure 2.15, described in Table 2.11, and summa-
rized in Table 2.12.
74 Universal Asynchronous Receiver/Transmitter (UART)
Bit 5 and bit 6 both show the state of the transmitting cycle. The difference
is that bit 5 turns high as soon as the transmitter holding register is empty,
whereas bit 6 indicates that also the shift register which outputs the bits on
the line is empty.
2.5 UART Functional Block Diagram 75
31 16
Reserved
R=0
15 7 6 5 4 3 2 1 0
R=0 R=0 R=1 R=1 R=0 R=0 R=0 R=0 R=0 R=0
Legend: R = Read only; −n = value after reset.
Figure 2.15 Line status register (LSR).
Access considerations:
• The RBR, THR, and DLL share one address. When DLAB = 1 in the
LCR, all accesses at the shared address are accesses to the DLL. When
DLAB = 0, reading from the shared address gives the content of the
RBR, and writing to the shared address modifies the THR.
• The IER and DLH share one address. When DLAB = 1 in the
LCR, accesses to the shared address read or modify the DLH. When
DLAB = 0, all accesses at the shared address read or modify the IER.
The DLL and DLH also have dedicated addresses. If dedicated addresses
are used, the DLAB bit can be kept cleared, so that the RBR, THR, and IER
are always selected at the shared addresses.
The divisor LSB latch (DLL) is shown in Table 2.16.
Table 2.17 Power and emulation management register (PWREMU_MGMT) field descrip-
tions
Bit Field Value Description
31–16 Reserved 0 Reserved
15 Reserved 0 Reserved. This bit must always be written as 0.
14 UTRST UART transmitter reset. Resets and enables the transmitter.
0 = Transmitter is disabled and in reset state.
1 = Transmitter is enabled.
13 URRST UART receiver reset. Resets and enables the receiver.
0 = Receiver is disabled and in reset state.
1 = Receiver is enabled.
12–1 Reserved 1 Reserved
0 FREE Free-running enable mode bit. This bit determines the
emulation mode functionality of the UART. When halted, the
UART can handle register read/write requests, but does not
generate any transmission/reception, interrupts or events.
0 = If a transmission is not in progress, the UART halts
immediately. If a transmission is in progress, the UART halts
after completion of the one-word transmission.
1 = Free-running mode is enabled. UART continues to run
normally.
31 Reserved 16
R-0
15 8 7 6 5 4 3 2 1 0
6
Reserved OSM_SEL
R-0 R/w-0
writing the transmit FIFO. This signal is used as an enable by the transmit
data counter and the transmit block. The transmit data counter keeps count
of the number of data bits transmitted onto tx. These signals are provided by
the transmit control block. The parity counter counts the number of bits that
were high in the 8 bits of data being transmitted. The transmit control block
controls the whole process of transmission. It is modeled in the form of a state
machine.
Receive FIFO: The FIFO is 8-bit wide and 32-byte deep. It receives control
signals from the serial receive block. The data are received from the receive
block written into its buffer. The write pointer is cleared when the write
pointer reaches its maximum limit before further increment.
Reception: The UART receiver section includes a receiver shift register
(RSR) and a receiver buffer register (RBR). When the UART is in the FIFO
mode, RBR is a 16-byte FIFO (receiver FIFO). Timing is supplied by the
receiver clock. Receiver section control is a function of the UART line control
register (LCR). Based on the settings chosen in LCR, the UART receiver
accepts the following from the transmitting device:
• 1 START bit
• 5, 6, 7, or 8 data bits
• 1 PARITY bit (optional)
• 1 STOP bit (any other STOP bits transferred with the above data are not
detected)
RSR receives the data bits from the UARTn_RXD pin. Then, RSR con-
catenates the data bits and moves the resulting value into RBR (or the receiver
FIFO). The UART also stores three bits of error status information next to
each received character to record a parity error, framing error, or break.
2.7 UART Errors 87
2.8.2 Operation
The operation of a USART is closely related to the protocol in use. This
section only provides a few general notes.
• USARTs in synchronous mode transmit data in frames. In synchronous
operation, characters must be provided on time until a frame is complete;
if the controlling processor does not do so; this is an “underrun error,”
and transmission of the frame is aborted.
• USARTs operating as synchronous devices used either character-
oriented or bit-oriented mode. In character (STR and BSC) modes, the
device relied on particular characters to define frame boundaries; in
bit (HDLC and SDLC) modes, earlier devices relied on physical-layer
signals, while later devices took over the physical-layer recognition of
bit patterns.
• A synchronous line is never silent; when the modem is transmitting, data
are flowing. When the physical layer indicates that the modem is active,
a USART will send a steady stream of padding, either characters or bits
as appropriate to the device and protocol.
90 Universal Asynchronous Receiver/Transmitter (UART)
Advantages
• Only two wires are used.
• No clock signal is necessary.
• It has a parity bit to allow for error checking.
• The structure of the data packet can be changed as long as both sides are
set up for it being a well-documented and widely used method.
Disadvantages
• The size of the data frame is limited to a maximum of 9 bits.
• It doesn’t support multiple slave or multiple master systems.
• The baud rates of each UART must be within 10% of each other.
CS C/D RD WR Operation
1 X X X Invalid
0 0 0 1 DataCPU 8251
0 0 1 0 DataCPU 8251
0 1 0 1 Status wordCPU 8251
0 1 1 0 Control wordCPU 8251
92 Universal Asynchronous Receiver/Transmitter (UART)
In this way, this unit selects one of the three registers—data buffer
register, control register, status register.
Modem control (modulator/demodulator): A device converts analog sig-
nals into digital signals and vice versa and helps the computers to communi-
cate over telephone lines or cable wires. The following are active-low pins of
Modem.
• DSR: Data set ready signal is an input signal.
• DTR: Data terminal ready is an output signal.
• CTS: It is an input signal that controls the data transmit circuit.
• RTS: It is an output signal that is used to set the status RTS.
Transmit buffer: This block is used for parallel to serial converter that
receives a parallel byte for conversion into serial signal and further trans-
mission onto the common channel.
• TXD: It is an output signal; if its value is one, the transmitter will
transmit the data.
Transmit control: This block is used to control the data transmission with
the help of following pins:
• TXRDY: It means transmitter is ready to transmit data character.
• TXEMPTY: An output signal which indicates that TXEMPTY pin has
transmitted all the data characters and transmitter is empty now.
• TXC: An active-low input pin that controls the data transmission rate of
transmitted data.
Receive buffer: This block acts as a buffer for the received data.
• RXD: An input signal that receives the data.
Receive control: This block controls the receiving data.
• RXRDY: An input signal indicates that it is ready to receive the data.
• RXC: An active-low output signal that controls the data transmission
rate of received data.
• SYNDET/BD: An input or output terminal. External synchronous
mode—input terminal, and asynchronous mode—output terminal.
3
Serial Data Standards RS-232
3.1 Introduction
In Chapter 1, we introduced the concept of serial communications, the placing
of one bit after another on a single media channel. Serial communication, as
mentioned before, is the most prevalent form of data communication.
In Chapter 2, we introduced UART and USART as the most widely used
serial communication protocol in use to communicate between devices. The
external signaling levels that are used between different equipment are not
generated by UART: UART does not give any electrical characteristics. An
interface is used to convert the logic level signals of the UART to the external
signaling levels. The interface used is called Serial Data Standard. Examples
of standards for voltage signaling are RS-232, RS-422, and RS-485 from
the EIA. For embedded system applications, UARTs are commonly used
with RS-232. It is useful to communicate between microcontrollers and also
with PCs. MAX 232 is one of the example ICs which provide RS-232 level
signals. Besides the EIA RS standards, there is also a CCITT standard named
V.24 that resembles the specifications included in RS-232-C. Figure 3.1 is a
block diagram explaining the implementation of RS-232 and its function as
an interface for UART.
Figure 3.1 shows that the RS-232 interface works in combination with
UART (universal asynchronous receiver/transmitter). It is a piece of inte-
grated circuit integrated inside the processor or controller. It takes bytes and
transmits the individual bits in a sequential fashion in a frame. A frame is a
defined structure, carrying meaningful sequence of bit or bytes of data. The
frame of asynchronous system introduced in Section 3.3. The frame has a
start bit followed by 5–8 data bits, a parity bit (optional), and a stop bit. Once
data are changed into bits, separate line drivers are used to convert the logic
level of UART to RS-232 logic. Finally, the signals are transferred along the
interface cable at the specified voltage level of RS-232.
93
94 Serial Data Standards RS-232
Figure 3.2 Serial data exchange between PC and device using RS-232 protocol.
At the other end, the receiver end, the line driver interface converts
it into UART compatible logic levels. At the destination, a second UART
reassembles the bits into bytes. This is how RS-232 made the data exchange
compatible and reliable.
Figure 3.2 shows how this entire arrangement works.
As shown in Figure 3.3, the equipment at the far end of the connection is
named the DTE (Data Terminal Equipment, usually a computer or terminal)
device, has a male DB25 connector, and utilizes 22 of the 25 available pins for
signals or ground (DB25 and DB9 connectors are discussed latter in the chap-
ter). Equipment at the near end of the connection (the telephone line interface)
is named the DCE (Data Circuit-terminating Equipment, usually a modem)
device, has a female DB25 connector, and utilizes the same 22 available pins
for signals and ground. DCE devices are sometimes called “Data Commu-
nications Equipment” instead of Data Circuit-terminating Equipment. The
cable linking DTE and DCE devices is a parallel straight-through cable with
no cross-overs or self-connects in the connector hoods. If all devices exactly
3.1 Introduction 95
Figure 3.3 RS-232 (EIA232) communication function and connector types for a personal
computer and modem.
followed this standard, all cables would be identical, and there would be no
chance that an incorrectly wired cable could be used. This drawing shows the
orientation and connector types for DTE and DCE devices:
Although serial communication is slower than parallel communication,
which allows the transmission of an entire byte at once, it is simpler and
can be used over longer distances because of lower power consumption. For
example, the IEEE 488 standard for parallel communication requires that the
cabling between equipment can be no more than 20 m total, with no more than
2 m between any two devices. RS-232/RS-485/RS-449 cabling, however, can
extend 1200 m or greater.
Serial data transmission standards including RS-232, RS-422, RS-423,
and RS-485 were widely used for many data links, proving effective connec-
tivity for the day. Although not nearly as widely used today, they can still be
found in some areas.
Another element needed for completing the communication between the
two communicating ends is the cables. Serial data transmission links used
cables with a variety of different functions to enable data to be sent reliably
between two equipment. Although a number of different wires were often
used within a cable, they did not require nearly as many as the systems that
sent parallel data.
This chapter focuses on three EIA/TIA serial standards for 232, 422,
and 485 as well as the ancillary 423, 449, and 530 standards. The chapter
will cover also the 20 mA current loops. Since the United States now sits
on the international standards committees, the EIA/TIA standards have their
equivalency in ISO standards, and indeed, most have been changed to meet
the ISO standards.
It is important to mention here that serial interface to the PC is being
accomplished by newer and much faster serial technologies. Chapter 4 will
96 Serial Data Standards RS-232
focus on four PC-based standards, USB 2.0, Firewire (IEEE 1394), SATA,
and PCIe, that will impact industrial use and applications.
“11011101” to the DCE device and DCE sends binary data “11010101” to
the DTE device.
As will be discussed latter, RS-232 describes the common voltage levels,
electrical standards, operation mode, and number of bits to be transferred
from DTE to DCE. This standard is used for the transmission of information
exchange over the telephone lines.
The RS-232 standard underwent several revisions. The C issue, known as
RS-232C, was issued in 1969 to accommodate the electrical characteristics
of the terminals and devices that were being used at the time.
The RS-232 standard underwent further revisions, and in 1986, Revision
D was released (often referred to as RS-232D). This revision of the RS-232
standard was required to incorporate various timing elements and to ensure
that the RS-232 standard harmonized with the CCITT standard V.24, while
still ensuring interoperability with older versions of RS-232 standard.
Further updates and revisions have occurred since then and the current
version is TIA-232-F issued in 1997 under the title: “Interface between Data
Terminal Equipment and Data Circuit-Terminating Equipment Employing
Serial Binary Data Interchange.”
The name of the RS-232 standard has changed during its history several
times as a result of the sponsoring organization. As a result, it has variously
been known as EIA RS-232, EIA-232, and most recently as TIA-232.
Start bit: The data are sent serially on RS-232; each bit is sent one after the
next because there is only one data line in each direction. This mode of data
3.3 RS-232 Serial Data Transmission: Data Timing 101
transmission also requires that the receiver knows when the actual data bits
are arriving so that it can synchronize itself to the incoming data.
Taking into consideration that the data line has two states, on and off,
and that an idle line is always on. To achieve synchronization, when the
instrument or computer wants to send data, it sets the line to off, that is, logic
0: this is the Start bit. The bits immediately after the start bit are therefore
the data bits.
Data: The start bit is followed by the data itself and there are normally
seven or eight bits (LSB sent first and MSB sent last). The receiver obviously
has to know how many data bits to expect, and there are often small dual
in line switches either on the back of the equipment or inside it to set this
information.
Data on RS-232 are normally sent using ASCII (American Standard Code
for Information Interchange). However other codes including the Murray
Code or EBCDIC (Extended Binary Coded Decimal Interchange Code) can
be used equally well.
Parity bit: After the data itself, a parity bit is sent. Parity is the state of
being either odd or even. In serial communication, parity may be used to
check for errors in the transmission of data. When performing a parity check,
the instrument or PC sending messages counts the number of 1’s in a group of
data bits. Depending on the result, the value of another bit, the Parity Bit, is
set. The device receiving the data also counts the 1’s and checks whether
the Parity Bit is as it should be. Parity is a rudimentary error checking
mechanism. It can detect a single bit in error in a transmitting message, but
if 2 bits happened to be wrong it would not pick this up. It also provides no
help as to which bit is wrong (parity is not error correcting). Other error
checking mechanisms may be used.
To perform a parity check, the computer and the instrument must obvi-
ously agree on how they are calculating the Parity Bit. Are they setting it on
for an even or odd number of 1’s? When a device uses Even Parity, the data
bits and the parity bit will always contain an even number of 1’s. The reverse
is true for Odd Parity. Since the parity bit is optional and can be Odd or Even,
it requires setting defining the parity type.
Note: Mark and Space Parity: Two other parity options often available in
driver software are Mark and Space. These aren’t effective in error checking.
Mark means the device always sets the Parity Bit to 1 and Space always to 0.
Stop bit: Finally, a stop bit is sent. The Stop Bit is present to allow the
instrument and computer to re-synchronize should anything go wrong: noise
102 Serial Data Standards RS-232
on the line masking the start bit, for example. The period of time between the
start and stop bit is constant, according to the baud rate and number of data
and parity bits. The stop bit is always on. If the receiver detects an off value
when the stop bit should be present, it knows there has been an error.
Setting of stop bit: The stop bit is not actually 1 bit but a minimum length
of time the line must be on at the end of each data transmission. On PCs, this
is normally equal to 1 or 2 bits, and the user must specify this in the driver
software. Although 1 stop bit is most common, selecting 2 will at worst slow
the message down slightly. (You might see an option to set the stop bit to 1.5.
This is only used when the number of data bits is less than 7. If this is the
case, then ASCII characters cannot be transmitted and so 1.5 is rarely used.)
Note: RS-232 data transmission is normally asynchronous. However, transmit
and receive speeds must obviously be the same. A certain degree of tolerance
is allowed. Once the start bit is sent, the receiver will sample the center of
each bit to see the level. Within each data word, the synchronization must
not differ by more than half a bit length; otherwise, the incorrect data will
be seen. Fortunately, this is very easy to achieve with today’s accurate bit or
baud rate generators.
Example: Figure 3.6 is an example showing how the data frame is composed
of and synchronized with the clock signal. This example uses an 8-bit word
with even parity and 1 stop bit also referred to as an 8E1 setting.
Figure 3.8 Logic states are assigned to the voltage ranges shown here. Note that this is a
“negative logic” convention, which is the reverse of that used in most modern digital designs.
Table 3.3 Voltage states for the control signals as these are widely used within RS-232
RS-232 Control Line Voltage Levels
Control Voltage Levels (volts) Logical State
−3 to −25 Off
+3 to +25 On
Figure 3.9 Timing diagram shows both TTL (bottom) and RS-232 signals sending
0b01010101.
must guarantee the compatibility between voltages on the two sides. In many
cases, this matter needs to use “level conversion” circuits. “Level Conversion”
circuits will be discussed in Section 3.7. To discuss such “level conversion”
circuits, it is important to start here by considering the voltage (logic) level of
TTL and LVTTL logic families.
TTL Logic Level: TTL (Transistor-Transistor Logic) is the most widely used
logic. TTL is mostly used in ICs and gates, like 74xx logic gates. A major
drawback of the TTL logic is that most of the devices working on the TTL
logic consume a lot of current, even individual gates may draw up to 3–4 mA.
In TTL logic, a HIGH (or 1) is +5 V, whereas a LOW (or 0) is 0 V. But since
attaining exact +5 V and 0 V is practically not possible every time; various IC
manufacturers define TTL logic level range differently, but the usual accepted
range for a HIGH is within +3.5 ∼ +5.0 V, and the range for a LOW is 0 ∼
+0.8 V. Figure 3.9 is a timing diagram showing both TTL and RS-232 signals
while sending the binary 0101010101.
LVTTL Logic Level: LVTTL (Low Voltage Transistor–Transistor Logic) is
increasingly becoming popular these days, because of the nominal HIGH
voltages, and hence lesser power consumption. By lowering the power supply
from 5 V to 3.3 V, switching power reduces by almost 60%.There are
several transistors and gates, which work on LVTTL logic. Atmel’s Atmega
108 Serial Data Standards RS-232
and to consist of parasitic elements only. “Ro ” and “Vo ” are chosen so that
the short-circuit current does not exceed 500 mA. The cable length is not
specified in the standard; acceptable operation is experienced with cables that
are less than 25 ft in length.
It is important to note here that the equivalent circuit of Figure 3.11
represents all signal lines, regardless of whether they provide data, timing,
or control information.
voltage in the receiver to keep the signal above +3 V (logic “0”) to ensure
that the fail-safe requirement is met.
Figure 3.12 An acceptable pulse (top) moves through the transition region quickly and
without hesitation or reversal. Defective pulses (bottom) could cause data errors.
Off hook: A condition that occurs when a telephone or other user instrument
is in use that is during dialing or communicating. It was originally referred for
telephones that have separate earpiece (receiver) which hangs on the switch
hook until user wants to use it.
Secondary channel: These are the data channels and have same capability
as the first one. For example, Secondary Transmitted Data (STD), Secondary
Received Data (SRD), Secondary Request To Send (SRTS), Secondary Clear
To Send (SCTS), and Secondary Carrier Detect (SDCD).
Pin 20 – DTE Ready (DTR): This signal is asserted (logic “0”, positive volt-
age) by the DTE device when it wishes to open a communications channel. If
the DCE device is a modem, the assertion of DTE Ready prepares the modem
to be connected to the telephone circuit and, once connected, maintains the
connection. When DTE Ready is deasserted (logic “1”, negative voltage), the
modem is switched to “on-hook” to terminate the connection.
IMPORTANT: If the DCE device is not a modem, it may require DTE Ready
to be asserted before the device can be used, or it may ignore DTE Ready
altogether. If the DCE device (e.g., a printer) is not responding, confirm that
DTE Ready is asserted before you search for other explanations.
Pin 8 – Received Line Signal Detector (CD) (also called carrier detect):
This signal is relevant when the DCE device is a modem. It is asserted (logic
“0”, positive voltage) by the modem when the telephone line is “off-hook,” a
connection has been established, and an answer tone is being received from
the remote modem. The signal is deasserted when no answer tone is being
received or when the answer tone is of inadequate quality to meet the local
modem’s requirements (perhaps due to a noisy channel).
Pin 12 – Secondary Received Line Signal Detector (SCD): This signal
is equivalent to the Received Line Signal Detector (pin 8), but refers to the
secondary channel.
Pin 22 – Ring Indicator (RI): This signal is relevant when the DCE device is
a modem and is asserted (logic “0”, positive voltage) when a ringing signal is
being received from the telephone line. The assertion time of this signal will
approximately equal the duration of the ring signal, and it will be deasserted
between rings or when no ringing is present.
Pin 23 – Data Signal Rate Selector: This signal may originate either in
the DTE or DCE devices (but not both) and is used to select one of two
prearranged baud rates. The asserted condition (logic “0”, positive voltage)
selects the higher baud rate.
essential to ensure that the correct connections are being used. It can be
very difficult to fault-find when the wrong connections are made as nothing
happens. Checking the voltages are correct and that the correct pins have been
connected normally resolves the issues.
120 Serial Data Standards RS-232
Table 3.7 RS-232 DB9 pin definition for the DTE device
RS-232 9-pin signal definition for the DTE device – looking into the DTE connector
DTE RS-232 device is often a PC
Pin no. Circuit Name Abbreviation Source
1 Received line signal detect
2 Receive data RXD
3 Transmit data TXD
4 Data terminal ready DTR
5 Signal ground
6 Data set ready DSR DCE
7 Request to send RTS
8 Clear to send CTS
9 Ring indicator
Table 3.8 RS-232 DB9 pin definition for the DCE device
RS-232 9-pin signal definition for the DCE device – looking into the DCE connector
DCE device is often a modem
Pin No. Circuit Name Abbreviation Source
1 Received line signal detect
2 Transmit data TXD
3 Receive data RXD
4 Data terminal ready DTR
5 Signal ground
6 Data set ready DSR DCE
7 Clear to send CTS
8 Request to send RTS
9 Ring indicator
• DSR (data set ready): When DCE is turned on and has gone through the
self-test, it asserts DSR to indicate that it is ready to communicate.
• RTS (request to send): When the DTE device has byte to transmit, it
asserts RTS to signal the modem that it has a byte of data to transmit.
• CTS (clear to send): When the modem has room for storing the data it is
to receive, it sends out signal CTS to DTE to indicate that it can receive
the data now.
• DCD (data carrier detect): The modem asserts signal DCD to inform the
DTE that a valid carrier has been detected and that contact between it
and the other modem is established.
• RI (ring indicator): An output from the modem and an input to a PC
indicates that the telephone is ringing. It goes on and off in synchronous
with the ringing sound.
• RxD (received data): The RxD pin is the Data Receive pin. This is the
pin where the receiver receives data.
• TxD (transmitted data): The TxD pin is the Data Transmit pin. This is
the pin through which data are transmitted to the receiver.
• GND: Ground pin.
The above signals are divided into groups (Table 3.6): data, hand-
shake/control, and ground. In the following, the signals are given in more
details.
a. The Data Pins
Most serial port devices support full-duplex communication meaning that
they can send and receive data at the same time. Therefore, separate pins
are used for transmitting and receiving data. For these devices, the TD, RD,
and GND pins are used. However, some types of serial port devices support
only one-way or half-duplex communications. For these devices, only the
TD and GND pins are used. In the course of explanation, it is assumed that
a full-duplex serial port is connected to the DCE. The TD pin carries data
transmitted by a DTE to a DCE. The RD pin carries data that are received by
a DTE from a DCE.
b. The Control Pins or Handshaking Pins:
The 9-pin serial ports provide several control pins whose functions are to
signal the presence of connected devices and control the flow of data. The
control pins include RTS and CTS, DTR and DSR, and CD and RI.
The RTS and CTS Pins: The RTS and CTS pins are used to signal whether
the devices are ready to send or receive data. This type of data flow control,
122 Serial Data Standards RS-232
The DTR and DSR Pins: Many devices use the DSR and DTR pins to
signal if they are connected and powered. Signaling the presence of connected
devices using DTR and DSR follows these steps:
1. The DTE asserts the DTR pin to request that the DCE connect to the
communication line.
2. The DCE asserts the DSR pin to indicate it is connected.
3. DCE unasserts the DSR pin when it is disconnected from the communi-
cation line.
The DTR and DSR pins were originally designed to provide an alternative
method of hardware handshaking. However, the RTS and CTS pins are
usually used in this way and not the DSR and DTR pins. However, you should
refer to your device documentation to determine its specific pin behavior.
The CD and RI Pins: The CD and RI pins are typically used to indicate the
presence of certain signals during modem–modem connections. CD is used
by a modem to signal that it has made a connection with another modem or
has detected a carrier tone. CD is asserted when the DCE is receiving a signal
of a suitable frequency. CD is unasserted if the DCE is not receiving a suitable
signal. RI is used to indicate the presence of an audible ringing signal. RI is
asserted when the DCE is receiving a ringing signal. RI is unasserted when
the DCE is not receiving a ringing signal (e.g., it is between rings).
The terminal then starts sending the serial data to the modem. When the
terminal gets exhausted of the data, it asserts the RTS signal low indicating
the modem that it has not got any more data to be sent. The modem in turn
unasserts its CTS signal and stops transmitting.
The same way initialization and the handshaking processes are executed
at the other end. Therefore, it must be noted here that the very important
aspect of data communication is the definition of the handshaking signals
defined for transferring serial data to and from the modem.
A loopback test can, for example, verify if the used USB to serial RS-
232 adapter has been installed properly and if it can send and receive data
as intended. In a troubleshooting situation, this will help determining if a
communication problem is caused by the adapter, equipment, or the drivers.
3.4 RS-232 Serial Interface (also known as V24) 129
of the equipment to send and receive and generally check the operation of the
serial port.
RS-232 loopback connectors are very easy to make up. They can be made
very easily either for DB9 or DB25 way connectors.
The loopback plug connects serial inputs to serial outputs so that the port
may be tested. It usually consists of a connector without a cable and includes
internal wiring to reroute signals back to the sender. There is more than one
way to wire up a serial loopback connector. The connections given below
form a commonly used configuration. Although it may not be necessary to
incorporate all the handshaking connections for all applications, they have
nevertheless been incorporated so that the serial loopback connector should
work for all situations.
Next we give three examples of serial loopback test plug, and latter,
we introduce many others and a table depicts the pin assignments for most
loopback plugs and cables that may be used when testing a system.
3.5 Cables
Whenever RS-232 is used, RS-232 cables will be needed to provide the
required electrical connection. These cables can take a variety of forms in
terms of the physical methods used for construction as well as the number of
connections that are incorporated within the overall RS-232 cable.
When constructing a cable, it should be remembered that not all the sig-
nals provided within RS-232 standard need to be implemented in a practical
3.5 Cables 133
RS-232 data cable. As a result, there are many design varieties for serial data
cables. Such design varieties of serial data cables may be seen on the Internet
and elsewhere.
In addition to this, further confusion is caused by the fact that RS-232
was designed to connect modems and terminal devices or teleprinters so that
telephone lines could be used to transmit data over the telephone system,
and serial data cables were required to connect the equipment at the remote
end. This intended application for RS-232 gives rise to the terminology
associated with these serial data connections, that is, DCE (Data Commu-
nications Equipment or Modem) and the DTE (Data Terminal Equipment or
teleprinter).
Handshaking is another factor that has to be considered while studying
serial cables: Different data systems utilize different levels of handshaking
when using RS-232. Many configurations can be used to achieve handshak-
ing.
The above discussion highlights the fact of having large varieties of RS-
232 serial cable. This is the subject of this section.
Tx, Tr, and GND are used to complete the communication. The transmit pins
of the two devices are connected together exactly as the receiving pins. The
GRD pins are connected, also, together.
extended from DB25 Female to DB25 Male. There are no crossovers or self-
connects present. This cable can be used to connect modems, printers, or any
serial device that uses a DB25 connector to a PC’s serial port.
This cable may also serve as an extension cable to increase the distance
between computer and serial device. This can be used up to 25 ft separation
between devices. In case if the separation exceeds 25 ft, booster is needed.
Caution: The male end of this cable (right) also fits a PC’s parallel printer
port. Accordingly, this cable may be used to extend the length of a printer
cable, but the user must avoid attaching a serial device to the computer’s
parallel port. Doing so may cause damage to both devices.
Figure 3.28 shows how two computers are communicating using DTE/DCE.
Figure 3.29 gives more details and the names of the different devices.
As can be seen in the diagram, the PC is the DTE and the modem is
the DCE. Communication between each PC and its associated modem is
accomplished using the RS-232 standard. Communication between the two
modems is accomplished via telecommunication.
It should be noted that although a microcomputer is usually the DTE in
RS-232 applications, this is not mandatory according to a strict interpretation
of the standard.
Many applications that use serial communication today do not involve
modem: null modem communication. A serial null modem configuration
with DTE/DTE communication is not so well defined, especially when it
comes to flow control. The terminology null modem for the situation where
two computers communicate directly is so often used nowadays that most
3.5 Cables 137
people don’t realize anymore the origin of the phrase and that a null modem
connection is an exception, not the rule.
In history, practical solutions were developed to let two computers talk
with each other using a null modem serial communication line. In most
situations, the original modem signal lines are reused to perform some sort
of handshaking. Handshaking can increase the maximum allowed commu-
nication speed because it gives the computers the ability to control the flow
of information. High amounts of incoming data are allowed if the computer
is capable to handle it, but not if it is busy performing other tasks. If no flow
control is implemented in the null modem connection, communication is only
possible at speeds at which it is sure the receiving side can handle the amount
information even under worst-case conditions.
138 Serial Data Standards RS-232
serial handshaking (data flow control) can help. To start the data flow, the
handshaking (the control signals) needs to indicate that data are ready to be
sent and received across equipment. In other words, the equipment at either
end of the link is ready to send the data and ready to receive the data.
In general, it is possible to identify two uses for handshaking:
1. To start the data flow
2. To guarantee no loss of data while communicating
Important note
Before discussing handshaking in some detail, it is important to note that:
• Handshake lines ensure a computer won’t transmit data if the receiving
computer is not ready.
142 Serial Data Standards RS-232
• It is crucial to note that you can tie handshake lines to fixed voltages.
This ensures the handshake lines will remain operational consistently.
• Furthermore, RS-232 handshaking is not always necessary. And even
though your RS-232 monitoring hardware may be equipped with inputs
and outputs that can be used for handshaking, there is no guarantee that
handshaking is needed to optimize the value of your hardware.
• Determining whether the application needs RS-232 handshaking may be
difficult. It needs carful study from the designer to decide about that.
makes use of the data channel between the two devices which reduces the
bandwidth. The reduction in bandwidth is in most cases, however, not so
astonishing that it is a reason to not use it.
When implementing RS-232 software handshaking, there are, as men-
tioned before, two commonly used methods: XON/XOFF and EXT/ACK.
The lines necessary are still the simple three line set of TX, RX, and
ground since the control characters are sent over the transmission line like
regular data. There is a function, for example, the function SetXMode allows
the user to enable or disable the use of two control characters, XON and
XOFF. These characters are sent by the receiver of the data to pause the
transmitter during communication.
are now off limits for data values. In ASCII transmissions, this typically does
not matter since these values are non-character values; however, if the data
are being transmitted via binary, it is very likely that these values could be
transmitted as data and the transmission would fail.
Another disadvantage is overhead cost: using bytes on the communication
channel takes up some bandwidth. One other reason is more severe. Hand-
shaking is mostly used to prevent an overrun of the receiver buffer, the buffer
in memory used to store the recently received bytes. If an overrun occurs,
this affects the way new coming characters on the communication channel
are handled. In the worst case where software has been designed badly, these
characters are thrown away without checking them. If such a character is
XOFF or XON, the flow of communication can be severely damaged. The
sender will continuously supply new information if the XOFF is lost, or never
send new information if no XON was received.
This also holds for communication lines where signal quality is bad. What
happens if the XOFF or XON message is not received clearly because of
noise on the line? Special precaution is also necessary that the information
sent does not contain the XON or XOFF characters as information bytes.
Therefore, serial communication using software flow control is only
acceptable when communication speeds are not too high, and the probability
that buffer overruns or data damage occur are minimal.
Other codes
Other codes are also used within what is effectively software control of an
RS-232 communication link. These codes are used for a variety of purposes
from indicating tabs, form feeds as well as providing audible “bell” warnings.
These codes are naturally focused on some of the older teletypes that used two
wire RS-232 links.
Although not all of the codes are used these days because many are
intended for use by the older teletype equipment, the same processes are
valid for modern equipment. This set of codes are known as control codes,
3.6 RS-232 Handshaking 145
which even gives rise to the “CTRL” key on today’s keyboards. Additionally,
the idea of software handshaking, although it was not so widely used in the
early days, is now well established and is usually the preferred method of
implementing control of communications systems in view of the flexibility
offered by processors.
itself. As soon as the RTS output is set, the CTS input will detect a high
logical value indicating that sending of information is allowed. This implies
that information will always be sent as soon as sending is requested by a
device if no further checking is present. To prevent this from happening,
two other pins on the connector are used, the data set ready DSR and the
data terminal ready DTR. These two lines indicate if the device attached is
working properly and willing to accept data. When these lines are cross-
connected (as in most null modem cables), flow control can be performed
using these lines. A DTR output is set, if that computer accepts incoming
characters. Handshaking using the four extra lines,CTS, RTS, DSR, and DTR,
besides the receive line Rx, the transmit line Tx and the ground is shown in
Figure 3.32 before. Sometimes this configuration is called “six signal lines”
handshake (Rx, Tx, CTS, RTS, DSR, and DTR).
that remote modem has received a RTS ON condition from its terminal and
remote DTE is in control over the carrier line. RXD stands for receive data
from modem to DTE. TXD transmits data from DTE to modem. The DTR
data terminal ready pin is generally on when terminal is ready to establish
communication channel through its modem. But when DTR does not want
to accept calls from remote terminal, the circuit is off. Both the modems
switch on their Data Set Ready circuit on when communication path has been
established between two sites. Now, when the terminal is ready to transmit,
it switches the Request to Send circuit on indicating local modem that it is
ready to send data. This request gets passed on to remote modem. The RTS
controls the direction of data transmission. Once terminal is ready to transmit
local modem switches on the CTS circuit to indicate that it is ready to receive
the data from DTE. It also gains control over the telephone line. Next when
the modem receives the call, the Ring Indicator switches on/off informing
DTE that a call is coming to indicate remote modem is requesting dial-up.
This is a simple handshaking system with eight signal lines.
In all null modems, the three wires Tx, Rx, and ground are in use. Using
the three wires may arise some problems in some circumstances: if either of
the two devices checks the DSR or CD inputs. These signals normally define
the ability of the other side to communicate. As they are not connected, their
signal level will never go high. This might cause a problem.
The same holds for the RTS/CTS handshaking sequence. If the software
on both sides is well structured, the RTS output is set high and then a waiting
cycle is started until a ready signal is received on the CTS line. This causes
the software to hang because no physical connection is present to either CTS
line to make this possible. The only type of communication which is allowed
on such a null modem line is data-only traffic on the cross-connected Rx/Tx
lines.
This limits the use of this null modem cable. For example, this null
modem cable can be used when communicating with devices which do
not have modem control signals like electronic measuring equipment, etc.
Communication links like those present in the Norton Commander program
can also use this null modem cable.
It is important to note that with this simple null modem cable, no hardware
flow control can be implemented. The only way to perform flow control is
with software flow control using the XOFF and XON characters.
possibility for the software to hang if it checks the modem signal lines in a
proper way. With this null modem cable, good written programs will perform
worse than badly written programs.
To overcome this problem and still be able to use a cheap null modem
communication cable with only three lines in it, a fake null modem cable
layout has been defined. The null modem cable with loopback handshaking
resulted from this, see Figure 3.35.
The main purpose of this null modem cable is to let well-defined software
think there is handshaking available, with a null modem cable which has no
provisions for it.
Compatibility issues
Consider first the DSR signal (pin 6). This input indicates that the other side
is ready to start communicating. In the layout, the line is linked back to the
DTR output (pin 4). This means that the software doesn’t see the ready signal
of the other device, but its own. The same holds for the CD input (pin 1).
The assumption is that if software has been written to check the DSR line to
test communication availability, it will probably also set the DTR output to
indicate its own state. This is true for at least 99% of all serial communication
3.6 RS-232 Handshaking 151
software. This implies that at least 99% of all serial communication software
is capable of faking its own DSR check with this null modem cable.
The same trick is used with the CTS input. In the original use, RTS is set,
and then CTS is checked before starting the communication. By setting the
RTS output (pin 7), the CTS input on the same connector (pin 8) is receiving
clearance immediately. There is no possibility of a software hangup because
of dangling RTS requests.
Compatibility issues
This null modem cable is the best of two worlds. There is the possibility of
hardware flow control without being incompatible with the original way flow
152 Serial Data Standards RS-232
control was used with DTE/DCE communication. Let us first consider the
RTS/CTS flow control lines present on pins 7 and 8. As with the loopback
null modem cable, these signals are not connected to the other device, but
directly looped back on the same connector. This means that RTS/CTS flow
control is allowed to be used in the software, but it has no functional meaning.
Only when the software at the other side checks the CD signal at pin 1, the
RTS information will reach the other device. This would however be only
the case in specifically developed software which uses the CD input for this
purpose.
More important, however, is the cross-connection of the DSR (pin 6) and
DTR (pin 4) lines. By cross connecting these lines, their original function
is simulated pretty well. The DTR output is used to signal the other device
that communication is possible. This information is read on the DSR input,
the same input used for this purpose with modem communication. Because
of this cross connection, the DTR output line can be used for simple flow
control. Incoming data are allowed when the output is set, and blocked if the
output is not set.
Software using only the RTS/CTS protocol for flow control cannot take
advantage of the partial handshaking null modem cable. Most software,
however, will also check the DSR line and in that case – when using the
3.6 RS-232 Handshaking 153
null modem cable with partial handshaking – the best possible hardware flow
control can be achieved which is still compatible with the original use with
modems.
Compatibility issues
The null modem cable with full handshaking does not permit the older way of
flow control to take place. The main incompatibility is the cross-connection of
the RTS and CTS pins. Originally, these pins are used for a question/answer
type of flow control. When the full handshaking null modem cable is used,
there is no request anymore. The lines are purely used for telling the other
side if communication is possible.
The main advantage of this cable is that there are two signaling lines in
each direction. Both RTS and DTR outputs can be used to send flow control
information to the other device. This makes it possible to achieve very high
154 Serial Data Standards RS-232
communication speeds with this type of null modem cable, provided that the
software has been designed for it. Because of the high possible connection
speed, this null modem cable can be used with Interlink to connect two MS-
DOS PCs.
This is the type of cable Microsoft recommends for the direct cable
connection in their knowledge base article. For the DB9 connector, they
also added a connection of DTR to CD on each connector but they didn’t
define this connection for the DB25 connector version and they also didn’t
3.6 RS-232 Handshaking 155
4.1 Introduction
This chapter continues the discussion about RS-232. The chapter introduces
the following topics:
• Practical RS-232 Implementation
• RS-232 Applications
• RS-232 Application Limitations
• Advantages and Disadvantages of RS-232
• Difference between RS-232 and UART
157
158 RS-232 Implementation, Applications, and Limitations
signals necessary for serial communication are generated and received by the
Universal Asynchronous Receiver/Transmitter (UART).
The RS-232 line driver/receiver IC performs the level translation neces-
sary between the CMOS/TTL and RS-232 interface.
The UART just mentioned performs the “overhead” tasks necessary for
asynchronous serial communication.
For example, the asynchronous nature of this type of communication
usually requires that start and stop bits be initiated by the host system to
indicate to the peripheral system when communication will start and stop.
Parity bits are also often employed to ensure that the data sent have not been
corrupted. The UART usually generates the start, stop, and parity bits when
transmitting data and can detect communication errors upon receiving data.
The UART also functions as the intermediary between byte-wide (parallel)
and bit-wide (serial) communication; it converts a byte of data into a serial
bit stream for transmitting and converts a serial bit stream into a byte of data
when receiving.
Now that an elementary explanation of the TTL/CMOS to RS-232
interface has been provided we can consider some “real world” RS-232
applications. It has already been noted that RS-232 applications rarely follow
the RS-232 standard precisely. Perhaps the most significant reason this is true
4.2 Practical RS-232 Implementation 159
is due to the fact that many of the defined signals are not necessary for most
applications.
As such, the unnecessary signals are omitted. Many applications, such as
a modem, require only nine signals (two data signals, six control signals, and
ground).
Other applications may require only five signals (two for data, two for
handshaking, and ground), while others may require only data signals with
no handshake control.
We will begin our investigation of “real-world” implementations by first
considering the typical modem application.
Request to Send (RTS): When the host system (DTE) is ready to transmit
data to the peripheral system (DCE), RTS is turned ON. In simplex and
duplex systems, this condition maintains the DCE in receive mode. In half-
duplex systems, this condition maintains the DCE in receive mode and
disables transmit mode. The OFF condition maintains the DCE in transmit
mode. After RTS is asserted, the DCE must assert CTS before communication
can commence.
Clear to Send (CTS): CTS is used along with RTS to provide handshaking
between the DTE and the DCE. After the DCE sees an asserted RTS, it turns
CTS ON when it is ready to begin communication.
Data Set Ready (DSR): This signal is turned on by the DCE to indicate that
it is connected to the telecommunication line.
Data Carrier Detect (DCD): This signal is turned ON when the DCE is
receiving a signal from a remote DCE which meets its suitable signal criteria.
This signal remains ON as long as a suitable carrier signal can be detected.
Data Terminal Ready (DTR): DTR indicates the readiness of the DTE. This
signal is turned ON by the DTE when it is ready to transmit or receive data
from the DCE. DTR must be ON before the DCE can assert DSR.
Ring Indicator (RI): RI, when asserted, indicates that a ringing signal is
being received on the communication channel. The signals described above
form the basis for modem communication. Perhaps the best way to under-
stand how these signals interact is to give a brief step-by-step example of a
modem interfacing with a PC. The following steps describe a transaction in
which a remote modem calls a local modem:
1. The local PC monitors the RI (Ring Indicator) signal via software.
2. When the remote modem wants to communicate with the local modem,
it generates an RI signal. This signal is transferred by the local modem
to the local PC.
3. The local PC responds to the RI signal by asserting the DTR (Data
Terminal Ready) signal when it is ready to communicate.
4. After recognizing the asserted DTR signal, the modem responds by
asserting DSR (Data Set Ready) after it is connected to the communica-
tion line. DSR indicates to the PC that the modem is ready to exchange
further control signals with the DTE to commence communication.
When DSR is asserted, the PC begins monitoring DCD for indication
that data are being sent over the communication line.
4.2 Practical RS-232 Implementation 161
5. The modem asserts DCD (Data Carrier Detect) after it has received a
carrier signal from the remote modem that meets the suitable signal
criteria.
6. At this point, data transfer can begin. If the local modem has full-duplex
capability, the CTS (Clear to Send) and RTS (Request to Send) signals
are held in the asserted state. If the modem has only half-duplex capa-
bility, CTS and RTS provide the handshaking necessary for controlling
the direction of the data flow. Data are transferred over the RD and TD
signals.
7. When the transfer of data has been completed, the PC disables the DTR
signal. The modem follows by inhibiting the DSR and DCD signals. At
this point, the PC and modem are in the original state described in step
number 1.
One limitation, the fact that over 20 signals have been defined by the standard,
has already been addressed – simply do not use all of the signals or the 25-pin
connector if they are not necessary.
Other limitations in the standard are not necessarily as easy to correct,
however.
devices still maintain a maximum 30 V/ms maximum slew rate to reduce the
likelihood of cross-talk between adjacent signals.
Another factor that limits the cable length is the use of common earth.
Use of a common earth or ground limits the length of the cable as the ground
will degrade over distance.
• The handshaking and control lines of the interface are intended for the
setup and takedown of a dial-up communication circuit; in particular,
the use of handshake lines for flow control is not reliably implemented
in many devices.
• No method is specified for sending power to a device. While a small
amount of current can be extracted from the DTR and RTS lines, this is
only suitable for low-power devices such as a computer mouse. This
limits the usefulness as every device must have its own independent
power supply.
• The 25-pin D-sub connector recommended in the standard is large
compared to current practice.
169
170 RS-232 Variants RS-422/RS-423, RS-449, RS-485, and EIA-530
unbundle the mechanical aspects of the standard from the electrical, with the
former becoming the RS-449 standards track.
The primary difference between RS-422 and RS-423 was that the former
had a return line for every signal, while the later had a single shared signal
ground. This meant that RS-422 had double the number of signal wires.
Along with other changes, the number of connections began to grow to the
point where even RS-423, which was functionally similar to RS-232, no
longer fit in a DB25 connector. This led to the use of the larger DC-37, but
even that did not have enough pins to support RS-422, so this was “solved”
by adding the additional ground wires to a separate DE-9 connector. This
resulted in a “horrendous number of wires” and the conclusion in 1983 that
its “success... remains to be seen.”
RS-485 was introduced as an improvement over RS-422. RS-485
increases the number of devices that can be connected from 10 to 32 and
defines the electrical characteristics necessary to ensure adequate signal
voltages under maximum load.
The RS-449 serial data standard was also introduced as an enhancement
to RS-232. It was aimed at providing serial data transmission at speeds up to
2 Mbps while still being able to maintain compatibility with RS-232.
RS-449 standard was rarely used, although it could be found on
some network communication equipment. EIA-449-1 was rescinded in
January 1986 and superseded by EIA/TIA-530-A, and the final version
of EIA-449-1 was withdrawn in September 2002. The most widespread
use of RS-422/423, the early Apple Macintosh computers, used a sim-
ple 9-pin DIN connector and for inter-machine links used only three-wire
connectors.
In summary, in search for serial interfaces that can avoid some of the
limitations of RS-232, it is possible to identify the following serial interfaces
which are similar to RS-232:
• RS-422 (a high-speed system similar to RS-232 but with differential
signaling)
• RS-423 (a high-speed system similar to RS-422 but with unbalanced
signaling)
• RS-449 (a functional and mechanical interface that used RS-422 and
RS-423 signals – it never caught on like RS-232 and was withdrawn by
the EIA)
• RS-485 (a descendant of RS-422 that can be used as a bus in multidrop
configurations)
5.1 Introduction: RS-232 Variants – Background 171
5.1.1.1 RS-422
What is RS-422?
RS-422, also known as TIA/EIA RS-422-A Standard or X.27 standard, is
the serial connection historically used on Apple Macintosh computers. RS-
422, originated by the Electronic Industries Alliance (EIA), specifies the
electrical characteristics of a digital signaling circuit. RS-422 uses a differen-
tial electrical signal, as opposed to unbalanced signals referenced to ground
172 RS-232 Variants RS-422/RS-423, RS-449, RS-485, and EIA-530
with the RS-232. RS-422 provides for data transmission, using balanced, or
differential, signaling, with unidirectional/non-reversible, terminated or non-
terminated transmission lines, point to point, or multi-drop. In contrast to
EIA-485, RS-422/V.11 does not allow multiple drivers but only multiple
receivers. Differential transmission uses two lines each for transmit and
receive signals which results in greater noise immunity and longer distances
as compared to the RS-232. Twisting the lines helps to reduce the noise. The
noise currents induced by an external source are reversed in every twist.
Instead of amplifying each other as in a straight line, the reversed noise
currents reduce each other’s influence. Figure 5.1 explains this in more detail.
Differential signaling can transmit data at rates as high as 10 Mbit/s, or may
be sent on cables as long as 1500 m. (Note: More discussion about twisted
pair and differential signals are given while discussing RS-485). Some sys-
tems directly interconnect using RS-422 signals, or RS-422 converters may
be used to extend the range of RS-232 connections. The RS-422 standard only
defines signal levels; other properties of a serial interface, such as electrical
connectors and pin wiring, are part of the RS-449 and RS-530 standards. The
mentioned advantages make RS-422 a better fit for industrial applications.
Revision B of RS-422, published in May 1994, was reaffirmed by the
Telecommunications Industry Association in 2005.
the maximum data rate decreases as cable length increases. The maximum
cable length is not specified in the standard, but guidance is given in its
annex. (This annex is not a formal part of the standard, but is included for
information purposes only.) Limitations on line length and data rate vary with
the parameters of the cable length, balance, and termination, as well as the
individual installation. In Table 5.1, it is given a maximum length of 1500 m,
but this is with a termination and with applications that can tolerate greater
timing and amplitude distortion.
RS-422 specifies the electrical characteristics of a single balanced signal.
The standard was written to be referenced by other standards that specify
the complete DTE/DCE interface for applications which require a balanced
voltage circuit to transmit data. These other standards would define protocols,
connectors, pin assignments, and functions. Standards such as EIA-530 (DB-
25 connector) and EIA-449 (DC-37 connector) use RS-422 electrical signals.
Some RS-422 devices have 4 screw terminals for pairs of wire, with one pair
used for data in each direction.
RS-422 cannot implement a true multi-point communications network
such as with EIA-485 since there can be only one driver on each pair of
wires. However, one driver can fan-out to up to 10 receivers.
174 RS-232 Variants RS-422/RS-423, RS-449, RS-485, and EIA-530
5.2 RS-423
RS-423 serial information
Introduction to RS-423
The RS-423 standard is one of the lesser known serial communication stan-
dards. Its older brother RS-232 is widely known because serial ports with
this interface are present on almost all computer systems. RS-422 and RS-
485 are differential which makes them useful in applications where noise
immunity is an issue, like in industrial applications. The single-ended RS-
423 standard sits somewhere in-between these standards as an enhancement
of RS-232 with longer cable lengths and higher allowed data rates.
Although RS-423 is currently not widely implemented, it has seen a broad
usage in the late eighties of the previous century because of its backward
compatibility with RS-232. Hewlett Packard shipped their computers with a
serial interface capable of communicating on both RS-232 and RS-423 levels,
and Digital Equipment Corporation used the RS-423 signal levels on their
DEC Connect MMJ serial interface standard. Because RS-232 and RS-423
176 RS-232 Variants RS-422/RS-423, RS-449, RS-485, and EIA-530
5.3 RS-449
The RS-449 serial data standard was intended as an enhancement to RS-232.
It was aimed at providing serial data transmission at speeds up to 2 Mbps
while still being able to maintain compatibility with RS-232.
Although never applied on personal computers, this interface was found
on some network communication equipment. The RS-449 standard has now
been discontinued and may also be seen in some references as EIA-449, TIA-
449, and ISO 4902.
The RS-449 specification, also known as EIA-449 or TIA-449, defines
the functional and mechanical characteristics of the interface between data
terminal equipment, typically a computer, and data communications equip-
ment, typically a modem or terminal server. It was an effort to replace
RS-232C, offering much higher performance and longer cable lengths, but
emerged as an unwieldy system requiring both DC-37 and DE-9 connectors.
The effort was eventually abandoned in favor of RS-530, which used a single
DB-25 connector. The full title of the standard is “EIA-449 General Purpose
37-Position and 9-Position Interface for Data Terminal Equipment and Data
Circuit-Terminating Equipment Employing Serial Binary Data Interchange”.
5.3 RS-449 177
RS-449 interface
One of the ways in which the RS-449 data communications standard is able
to send at high speeds without stray noise causing interference is to use a
differential form of signaling, exactly as RS-422. Earlier data communica-
tion standards such as RS-232 used signaling that was referenced to earth,
and while this was easier to implement and cheaper to cable, it introduced
limitations into the system.
Slew rate effect on a square wave: red = desired output, green = actual output.
As discussed before, by using twisted wire pairs for the data lines, any
unwanted noise will be picked up by both wires together. As the RS-449
receivers use a differential input, and they are not referenced to ground, any
noise that is picked up does not affect the input. This means that higher levels
of noise can be tolerated without any degradation to the performance to the
data communications system.
For the RS-449 interface, 10 additional circuit functions have been
provided when compared to RS-232. Additionally, three of the original
interchange circuits have been abandoned.
In order to minimize any confusion that could easily occur, the circuit
abbreviations have been changed. In addition to this, the RS-449 interface
requires the use of 37-way D-type connectors and 9-way D-type connec-
tors, the latter being necessary when use is made of the secondary channel
interchange circuits.
5.4 RS-485
What Is RS-485?
RS-232, as detailed before, is an interface to connect one DTE, data terminal
equipment, to one DCE, data communication equipment, at a maximum
speed of 20 Kbps with a maximum cable length of 50 ft. This was sufficient
in the old days where almost all computer equipment were connected using
modems, but soon after people started to look for interfaces capable of one or
more of the following:
• Connect DTE’s directly without the need of modems
• Connect several DTE’s in a network structure
• Ability to communicate over longer distances
• Ability to communicate at faster communication rates
RS-485 is the most versatile communication standard in the standard
series defined by the EIA, as it performs well on all the four points. That
is why RS-485 is currently a widely used communication interface in data
acquisition and control applications where multiple nodes communicate with
each other.
RS-485 (also known as EIA-485, TIA-485(-A) Standard) is an improve-
ment over RS-422, because it increases the number of devices from 10 to 32
and defines the electrical characteristics necessary to ensure adequate signal
voltages under maximum load. With this enhanced multi-drop capability, it
is possible to create networks of devices connected to a single RS-485 serial
port. The noise immunity and multi-drop capability make RS-485 the serial
connection of choice in industrial applications requiring many distributed
devices networked to a PC or other controller for data collection, HMI, or
other operations. RS-485 is a superset of RS-422; thus, all RS-422 devices
may be controlled by RS-485. RS-485 is able to provide a data rate of 10
Mbps at distance s up to 50 ft. RS-485 hardware may also be used for serial
communication with up to 4000 ft of cable with a lower speed of 100 Kbps.
RS-485 uses, as RS-422, differential signals that results in longer distance
and higher bit rate.
Although RS-485 was never intended for domestic use, it found many
applications where remote data acquisition was required and also widely
used communication interface in control applications where multiple nodes
communicate with each other.
Table 5.4 summarizes the characteristics of RS-485.
5.4 RS-485 181
Differential signal lines also allow higher bit rates than possible with
non-differential connections. Therefore, RS-485 can overcome the practi-
cal communication speed limit of RS-232. Currently, RS-485 drivers are
produced that can achieve a bit rate of 35 Mbps.
of this, RS-485 and the others can be used in situations with a severe
ground level shift of several volts, where at the same time high bit rates
are possible because the transition between logical 0 and logical 1 is
only a few hundred millivolts.
4. RS-232 is the only interface capable of full-duplex communication. This
is, because on the other interfaces, the communication channel is shared
by multiple receivers and – in the case of RS-485 – by multiple senders.
RS-232 has a separate communication line for transmitting and receiving
which – with a well written protocol – allows higher effective data rates
at the same bit rate than the other interfaces. The request and acknowl-
edge data needed in most protocols does not consume bandwidth on the
primary data channel of RS-232.
5. RS-485 has the same distance and data rate specifications as RS-422 and
uses differential signaling but, unlike RS-422, allows multiple drivers
on the same bus. As depicted in Figure 5.2, each node on the bus can
include both a driver and receiver forming a multi-point star network.
Each driver at each node remains in a disabled high impedance state until
called upon to transmit. This is different than drivers made for RS-422
where there is only one driver and it is always enabled and cannot be
disabled.
RS-232 using simple interface converters that may include optical isolation
between the two circuits as well as surge suppression for any electrical
’spikes’ that may be picked up.
Using RS-485, it is possible to construct a multi-point data communi-
cations network. The standard specifies that up to 32 drivers or transmitters
along with 32 receivers can be used on a system. This means that there can be
32 nodes capable to both transmit and receive. This can be extended further
by using “automatic” repeaters and high-impedance drivers / receivers. In
this way, it is possible to have hundreds of nodes on a network. In addi-
tion to this, RS-485 extends the common mode range for both drivers and
receivers in the “tri-state” mode and with power off. Also, RS-485 drivers are
able to withstand “data collisions” (bus contention) problems and bus fault
conditions.
As RS-485 networks become larger, the problem of data collisions
becomes greater. This can be solved, at least in part by ensuring the hardware
units (converters, repeaters, micro-processor controls) are designed to remain
in a receive mode until they are ready to transmit data.
Another approach is to design a ’single master’ system. Here the master
initiates a communications request to a “slave node” by addressing that unit.
The hardware detects the start-bit of the transmission and thereby enables the
transmitter. Once the requested data are sent, the hardware reverts back into
a receive mode.
Advantages of RS-485
• Among all of the asynchronous standards mentioned above, this stan-
dard offers the maximum data rate.
• Apart from that special hardware for avoiding bus contention and,
• A higher receiver input impedance with lower Driver load impedances
is its other asset.
5.5 EIA-530
Interface Standards
Currently known as TIA-530-A, but often called EIA-530, or RS-530, is
a balanced serial interface standard that generally uses a 25-pin connector,
originally created by the Telecommunications Industry Association (TIA).
The standard is finalized in 1987 (revision A finalized in 1992), and the
specification defines the cable between the DTE and DCE devices. It is to be
5.5 EIA-530 187
used in conjunction with EIA-422 and EIA-423, which define the electrical
signaling characteristics. Because TIA-530 calls for the more common 25-pin
connector, it displaced the similar EIA-449, which also uses EIA-422/423,
but a larger 37-pin connector.
Two types of interchange circuits (“signals” or “leads”) between the
DCE and DTE are defined in TIA-530: Category I, which uses the balanced
characteristics of EIA-422, and Category II, which is the unbalanced EIA-
423. Most of the interchange circuits are Category I, with the exception of
Local Loopback (pin 18), Remote Loopback (pin 21), and Test Mode (pin
25) being Category II.
TIA-530 originally used Category I circuits for what is commonly called
“Data Set Ready” (DCE Ready, pins 6 and 22) and “Data Terminal Ready”
(DTE Ready, pins 20 and 23). Revision A changed these interchange circuits
to Category II (para 4.3.6 and 4.3.7 of the standard) and added a “Ring
Indicator” on pin 22. Pin 23 is grounded in TIA-530-A.
Confusion between the revisions has led to many incorrect wiring dia-
grams of this interface and most manufacturers still adhere to the original
TIA-530 standard. Care should be taken to ensure devices are of the same
standard before connecting to avoid complications.
The majority of the signals conform to the RS-422 standard and for the
majority of requirements requiring RS-422 signaling, the RS-530 cable is
suitable. Some of the link management controls signals are implemented
using V.10 (RS-423) single-ended interfaces, and a variant of this standard
called RS-530A / EIA-530A also uses V.10 for the DTR signal. Note that the
EIA standards have effectively replaced the RS standards and have now been
themselves superseded by TIA standards.
Interface Characteristics
RS-530 is a differential communications interface with some single-ended
link management signals, typically limited to a maximum throughput of
10 Mbps. Communications over distances exceeding 1000 m is possible
at low bit rates, the actual performance being mostly dependent on cable
specification. Separate clock lines are used for receiving and transmitting
data.
Interface Applications
EIA-530 interfaces are commonly found on communications equipment
in some parts of the world where high throughput and/or long distances
188 RS-232 Variants RS-422/RS-423, RS-449, RS-485, and EIA-530
are required. The interface also offers good noise immunity enabling reli-
able communications in environments where there are high levels of EMI
(electromagnetic interference).
Applications include high-speed connections between satellite modems
and host computer systems.
Pin Configuration
EIA-530, or RS-530, is a balanced serial interface standard that generally
uses a 25-pin connector. The R-S530 is not an actual interface, but a generic
connector specification. The connector pinning can be used to support RS-
422, RS-423, V.35, and X.21 to name the most popular ones (Table 5.7).
RS-530 is just like RS-422 and uses a differential signaling on a DB25 –
RS-232 format; EIA-530 Transmit (and the other signals) use a twisted pair
of wires (TD+ & TD-) instead of TD and a ground reference as in RS-232
or V.24. This interface is used for HIGH SPEED synchronous protocols.
Using a differential signaling allows for higher speeds over long cabling.
This standard is applicable for use at data signaling rates in the range from
20,000 to a nominal upper limit of 2,000,000 bits per second. Equipment
complying with this standard, however, need not operate over this entire data
signaling rate range. They may be designed to operate over a narrower range
as appropriate for the specific application.
References
[1] “Interface Between Data Terminal Equipment and Data Circuit-
Terminating Equipment Employing Serial Binary Data Interchange,”
TIA/EIA-232-F Standards, Electronics Industries Association Engineer-
ing Department.
[2] “Electrical Characteristics of Balanced Digital Interface Circuits,”
TIA/EIA-422-B Standards, Electronics Industries Association Engineer-
ing Department.
[3] “Standard for Electrical Characteristics of Generators and Receivers
for Use in Balanced Digital Multipoint Systems,” TIA/EIA-485-A
Standards, Electronics Industries Association Engineering Department.
[4] “The I2 C Specification,” Version 2.1, Philips Semiconductors.
[5] Aleaf, Abdul, “Microwire Serial Interface,” Application Note AN-452,
National Semiconductor.
[6] Goldie, John, “Summary of Well Known Interface Standards,” Applica-
tion Note AN-216, National Semiconductor.
[7] Nelson, Todd, “The Practical Limits of RS-485,” Application Note AN-
979, National Semiconductor.
[8] Wilson, Michael R., “TIA/EIA-422-B Overview,” Application Note AN-
1031, National Semiconductor.
[9] Goldie, John, “Ten Ways to Bulletproof RS-485 Interfaces,” Application
Note AN-1057, National Semiconductor.
6
Serial Peripheral Interface (SPI)
In the first chapter of the book, we introduced serial communication and the
most famous protocols: UART, SPI, I2C, CAN, etc. As a fact, the three most
common multi-wire serial data transmission formats that have been in use
for decades are I2C, UART, and SPI. Chapter 2 introduced the first serial
communication protocols: UART/USART. This chapter introduces to the
reader another serial communication protocol: Serial Peripheral Interface
(SPI). As a case study, the SPI of (AVR) microcontrollers will be discussed.
191
192 Serial Peripheral Interface (SPI)
Figure 6.2 A typical hardware setup using two shift registers to form an inter-chip circular
buffer.
194 Serial Peripheral Interface (SPI)
Figure 6.3
196 Serial Peripheral Interface (SPI)
As soon as the first clock pulse arrives, the shift registers come into
operation and the data in the registers is shifted by one bit towards the right.
This evicts bit A0 from Master and bit B0 from Slave. Since the Master and
Slave are connected to form a ring/circular buffer, the evicted bit occupies
the MSB position of the other device. Which means, bit A0 gets evicted from
Master and occupies MSB position in Slave’s shift register; whereas bit B0
gets evicted from Slave and occupies MSB position in Master’s shift register.
This first cycle is shown in Figure 6.3(b), while Figure 6.3(c) shows the
second cycle, etc. At the end of the clock pulses, the Master has completely
received B, and the Slave has received A.
As seen from Figure 6.3, during each SPI clock cycle, the following takes
place, which represents a full-duplex transmission:
• Master sends a bit to the MOSI line; Slave reads it from the same line.
• Slave sends a bit to the MISO line; Master reads it from the same line.
2. MISO (Master In Slave Out): This is the wire/signal which goes from
the output of Slave’s shift register to the input of the Master’s shift
register.
MISO pins on both the master and slave are ties together. Even though
the Signal in MISO is produced by the Slave, the line is controlled by
the Master. The Master generates a clock signal at SCLK and is supplied
to the clock input of the slave. Chip Select (CS) or Slave Select (SS) is
used to select a particular slave by the master.
Since the clock is generated by the Master, the flow of data is controlled
by the master. For every clock cycle, one bit of data is transmitted from
master to slave and one bit of data is transmitted from slave to master.
This process happens simultaneously and after 8 clock cycles, a byte
of data is transmitted in both directions and hence, SPI is a full-duplex
communication.
If the data have to be transmitted by only one device, then, as mentioned
before, the other device has to send something (even garbage or junk
data), and it is up to the device whether the transmitted data are actual
data or not.
This means that for every bit transmitted by one device, the other device
has to send one bit data, that is, the Master simultaneously transmits data
on MOSI line and receive data from slave on MISO line.
If the slave wants to transmit the data, the master has to generate the
clock signal accordingly by knowing when the slave wants to send the
data in advance.
3. SCK/SCLK (Serial Clock): This is the output of the clock generator
for Master and clock input for Slave.
The clock signal synchronizes the output of data bits from the master to
the sampling of bits by the slave. One bit of data is transferred in each
clock cycle, the speed of data transfer is determined by the frequency of
the clock signal. SPI communication is always initiated by the master
since the master configures and generates the clock signal.
The clock signal in SPI can be modified using the properties of clock
polarity and clock phase. These two properties work together to define
when the bits are output and when they are sampled. Clock polarity can
be set by the master to allow for bits to be output and sampled on either
the rising or falling edge of the clock cycle. Clock phase can be set for
output and sampling to occur on either the first edge or second edge
of the clock cycle, regardless of whether it is rising or falling. This is
discussed in the Section 6.4.
198 Serial Peripheral Interface (SPI)
Figure 6.4 SPI bus – single master multiple slaves: parallel configuration.
200 Serial Peripheral Interface (SPI)
signal is responsible for choosing a particular Slave. The Slave gets enabled
only when its input SS’ signal goes LOW.
A pull-up resistor between power source and chip select line is highly
recommended for each independent device to reduce cross-talk between
devices. This configuration is the one normally used in SPI. Since the MISO
pins of the slaves are connected together, they are required to be tri-state pins
(high, low, or high-impedance).
byte of data is shifted to slave 1. When the 2nd byte of data reaches slave 1,
the first byte is pushed into slave 2.
Finally, when the 3rd byte of data arrives into the first slave, the 1st byte
of data is shifted to slave 3 and the second byte of data is shifted to slave 2.
If the master wants to retrieve information from the slaves, it has to send
3 bytes of junk data to the slaves so that the information in the slaves comes
to the master.
Figure 6.7 A timing diagram showing clock polarity and phase. Red lines denote clock
leading edges, and blue lines, trailing edges.
Keeping synchronization in mind, Master’s role does not end with simply
generating clock pulses at a particular frequency (usually within the range of
10 kHz to 100 MHz). In fact, Master and Slave should agree on a particular
synchronization protocol as well, or else everything will go wrong and data
will get lost. This is where the concept of clock polarity (CPOL) and clock
phase (CPHA) comes in.
The timing diagram is shown in Figure 6.7. The timing applies to both the
master and the slave device.
• CPOL (Clock Polarity): This determines the base value of the clock,
that is, the value of the clock when SPI bus is idle.
– When CPOL = 0, base value of clock is zero, that is, SCK is LOW
when idle.
– When CPOL = 1, base value of clock is one, that is, SCK is HIGH
when idle.
• CPHA (Clock Phase): This determines the clock transition at which
data will be sampled/captured.
– When CPHA = 0, data are sampled at clock’s rising/leading edge.
– When CPHA = 1, data are sampled at clock’s falling/trailing edge.
Figure 6.8 shows the sampling edge and toggling edge during the four
modes.
6.4 Clock Polarity and Phase 203
Figure 6.8 Sampling edge and toggling edge during the four modes.
1 0 1 0
2 1 0 1
3 1 1 0
From Tables 6.1 and 6.2 and Figure 6.7, the four modes are summarized
as follows:
Mode 0:
Mode 0 occurs when Clock Polarity is LOW and Clock Phase is 0 (CPOL = 0
and CPHA = 0). During Mode 0, data transmission occurs during rising edge
of the clock.
6.4 Clock Polarity and Phase 205
Mode 1:
Mode 1 occurs when Clock Polarity is LOW and Clock Phase is 1 (CPOL =
0 and CPHA = 1). During Mode 1, data transmission occurs during falling
edge of the clock.
Mode 2:
Mode 2 occurs when Clock Polarity is HIGH and Clock Phase is 0 (CPOL
= 1 and CPHA = 0). During Mode 2, data transmission occurs during rising
edge of the clock.
Mode 3:
Mode 3 occurs when Clock Polarity is HIGH and Clock Phase is 1 (CPOL
= 1 and CPHA = 1). During Mode 3, data transmission occurs during rising
edge of the clock.
Each transaction begins when the slave-select line is driven to logic low
(slave select is typically an active-low signal). The exact relationship between
the slave-select, data, and clock lines depends on how the clock polarity
(CPOL) and clock phase (CPHA) are configured.
With non-inverted clock polarity (i.e., the clock is at logic low when slave
select transitions to logic low):
• Mode 0: Clock phase is configured such that data are sampled on the
rising edge of the clock pulse and shifted out on the falling edge of the
clock pulse. This corresponds to the first blue clock trace in the above
diagram. Note that data must be available before the first rising edge of
the clock.
• Mode 1: Clock phase is configured such that data is sampled on the
falling edge of the clock pulse and shifted out on the rising edge of the
clock pulse. This corresponds to the second blue clock trace in the above
diagram.
With inverted clock polarity (i.e., the clock is at logic high when slave
select transitions to logic low):
• Mode 2: Clock phase is configured such that data are sampled on the
falling edge of the clock pulse and shifted out on the rising edge of the
clock pulse. This corresponds to the first orange clock trace in the above
diagram. Note that data must be available before the first falling edge of
the clock.
• Mode 3: Clock phase is configured such that data are sampled on the
rising edge of the clock pulse and shifted out on the falling edge of the
206 Serial Peripheral Interface (SPI)
clock pulse. This corresponds to the second orange clock trace in the
above diagram.
Valid communications
Some slave devices are designed to ignore any SPI communications in which
the number of clock pulses is greater than specified. Others do not care,
ignoring extra inputs and continuing to shift the same output bit. It is common
for different devices to use SPI communications with different lengths, as, for
example, when SPI is used to access the scan chain of a digital IC by issuing
a command word of one size (perhaps 32 bits) and then getting a response of
a different size (perhaps 153 bits, one for each pin in that scan chain).
Interrupts
SPI devices sometimes use another signal line to send an interrupt signal to a
host CPU. Examples include pen-down interrupts from touchscreen sensors,
thermal limit alerts from temperature sensors, alarms issued by real time
clock chips, SDIO, and headset jack insertions from the sound codec in a cell
phone. Interrupts are not covered by the SPI standard; their usage is neither
forbidden nor specified by the standard.
6.4 Clock Polarity and Phase 207
Bit banging
In computer engineering and electrical engineering, bit banging is slang for
various techniques for data transmission in which software is used to generate
and process signals instead of dedicated hardware. Software directly sets
and samples the state of pins on a microcontroller and is responsible for all
parameters of the signal: timing, levels, synchronization, etc. In contrast to
bit banging, dedicated hardware (such as a modem, UART, or shift register)
handles these parameters and provides a (buffered) data interface in other
systems, so software is not required to perform signal demodulation. Bit
banging can be implemented at very low cost and is used in embedded
systems.
Bit banging allows the same device to use different protocols with min-
imal or no hardware changes required. In many cases, bit banging is made
possible because more recent hardware operates much more quickly than
hardware did when standard communications protocols were created.
In the following, two programs are given showing sending a byte on an
SPI bus.
uint8_t bit;
return byte_in;
}
{
int i;
// deselect device
output_high(SD_CS);
Disadvantages
• Requires more pins on IC packages than I2C, even in the three-wire
variant
• No in-band addressing; out-of-band chip select signals are required on
shared buses
• No hardware flow control by the slave (but the master can delay the next
clock edge to slow the transfer rate)
• No hardware slave acknowledgment (the master could be transmitting
to nowhere and not know it)
• Typically supports only one master device (depends on device’s hard-
ware implementation)
• No error-checking protocol is defined
• Without a formal standard, validating conformance is not possible
• Only handles short distances compared to RS-232, RS-485, or CAN-bus.
(Its distance can be extended with the use of transceivers like RS-422.)
• Many existing variations, making it difficult to find development tools
like host adapters that support those variations
• SPI does not support hot swapping (dynamically adding nodes).
• Interrupts must either be implemented with out-of-band signals or be
faked by using periodic polling similarly to USB 1.1 and 2.0.
• Some variants like dual SPI, quad SPI, and three-wire serial buses
defined below are half-duplex.
I/O modes can rival the read speed of parallel devices while still offering
reduced pin counts. This performance increase enables random access and
direct program execution from flash memory (execute-in-place).
Some of such SPI variants are introduced here.
6.6.2 Microwire
Microwire, often spelled µWire, is essentially a predecessor of SPI and a
trademark of National Semiconductor. It’s a strict subset of SPI: half-duplex
and using SPI mode 0. Microwire chips tend to need slower clock rates than
newer SPI versions, perhaps 2 MHz versus 20 MHz. Some Microwire chips
also support a three-wire mode.
Microwire/Plus
Microwire/Plus is an enhancement of Microwire and features full-duplex
communication and support for SPI modes 0 and 1. There was no specified
improvement in serial clock speed.
212 Serial Peripheral Interface (SPI)
Figure 6.12 Quad mode fast read sequence for Spansion S25FL016K or equivalent.
mode bits in just 8 clock cycles. The address is then followed with 2 dummy
bytes (4 clock cycles) to allow the device additional time to set up the initial
address.
After the address cycle and dummy bytes have been sent by the host,
the component begins sending data bytes; each clock cycle consists of a data
nibble spread across the 4 IO lines, for a total of two clock cycles per byte
of data. Compare this to the 16 clock cycles required when using simple read
transaction, and it is easy to see why quad mode is gaining popularity for high
speed flash memory applications. To create this sequence in the SPI Exerciser
command language, we would use the example code:
4m // Start in 4-wire mode
Note that we are changing from 4-wire mode to quad mode in the middle
of the transaction. In quad mode, the software automatically distributes
the data bytes among the IO lines using the same bit pattern depicted in
Figure 6.12.
6.6.6 QPI/SQI
Further extending quad SPI, some devices support a “quad everything” mode
where all communication takes place over 4 data lines, including commands.
This is variously called “QPI” (not to be confused with Intel QuickPath
Interconnect) or “serial quad I/O” (SQI).
This requires programming a configuration bit in the device and requires
care after reset to establish communication.
Note: The Intel QuickPath Interconnect (QPI) is a point-to-point pro-
cessor interconnect developed by Intel which replaced the front-side bus
(FSB) in Xeon, Itanium, and certain desktop platforms starting in 2008.
It increased the scalability and available bandwidth. Prior to the name’s
announcement, Intel referred to it as Common System Interface (CSI).
6.6 SPI Variants 215
6.7 Standards
The SPI bus is a de facto standard. However, the lack of a formal standard
is reflected in a wide variety of protocol options. Different word sizes are
common. Every device defines its own protocol, including whether it supports
commands at all. Some devices are transmit-only; others are receive-only.
Chip selects are sometimes active-high rather than active-low. Some protocols
send the least significant bit first.
Some devices even have minor variances from the CPOL/CPHA modes
described above. Sending data from slave to master may use the opposite
clock edge as master to slave. Devices often require extra clock idle time
before the first clock or after the last one, or between a command and its
response. Some devices have two clocks, one to read data, and another to
6.8 Applications 217
transmit it into the device. Many of the read clocks run from the chip select
line.
Some devices require an additional flow control signal from slave to
master, indicating when data are ready. This leads to a 5-wire protocol instead
of the usual 4. Such a ready or enable signal is often active-low and needs to
be enabled at key points such as after commands or between words. Without
such a signal, data transfer rates may need to be slowed down significantly,
or protocols may need to have dummy bytes inserted, to accommodate the
worst case for the slave response time. Examples include initiating an ADC
conversion, addressing the right page of flash memory, and processing enough
of a command that device firmware can load the first word of the response.
(Many SPI masters do not support that signal directly, and instead rely on
fixed delays.)
Many SPI chips only support messages that are multiples of 8 bits. Such
chips cannot interoperate with the JTAG or SGPIO protocols, or any other
protocol that requires messages that are not multiples of 8 bits.
There are also hardware-level differences. Some chips combine MOSI
and MISO into a single data line (SI/SO); this is sometimes called ’three-
wire’ signaling (in contrast to normal “four-wire” SPI). Another variation of
SPI removes the chip select line, managing protocol state machine entry/exit
using other methods. Anyone needing an external connector for SPI defines
their own: UEXT, JTAG connector, Secure Digital card socket, etc. Signal
levels depend entirely on the chips involved.
SafeSPI is an industry standard for SPI in automotive applications. Its
main focus is the transmission of sensor data between different devices
6.8 Applications
The full-duplex capability makes SPI very simple and efficient for single
master/single slave applications. Some devices use the full-duplex mode to
implement an efficient, swift data stream for applications such as digital
audio, digital signal processing, or telecommunications channels, but most
off-the-shelf chips stick to half-duplex request/response protocols.
SPI is used to talk to a variety of peripherals, such as:
1. Wired transmission of data (although the first preference is mostly
USART, but SPI can be used when we are using multiple slave or master
systems, as addressing is much simpler in SPI).
2. Wireless transmissions through ZigBee, 2.4GHz, etc.
218 Serial Peripheral Interface (SPI)
3. Communicate with FLASH and EEPROM memory. This gives the pos-
sibility of programming some of the microcontrollers, for example, AVR
chips
4. Control devices: audio codecs, digital potentiometers, DAC
5. It is also used to talk to various peripherals – like sensors, memory
devices, real-time clocks, communication protocols like Ethernet, ADC,
video game controllers, etc.
6. Interface with LCDs and SD cards
7. Read data from a real-time clock.
8. Any MMC or SD card (including SDIO variant)
For high-performance systems, FPGAs sometimes use SPI to interface as
a slave to a host, as a master to sensors, or for flash memory used to bootstrap
if they are SRAM-based.
Although there are some similarities between the SPI bus and the JTAG
(IEEE 1149.1-2013) protocol, they are not interchangeable. The SPI bus is
intended for high speed, on board initialization of device peripherals, while
the JTAG protocol is intended to provide reliable test access to the I/O
pins from an off board controller with less precise signal delay and skew
parameters. While not strictly a level sensitive interface, the JTAG protocol
supports the recovery of both setup and hold violations between JTAG devices
by reducing the clock rate or changing the clock’s duty cycles. Consequently,
the JTAG interface is not intended to support extremely high data rates.
SGPIO is essentially another (incompatible) application stack for SPI
designed for particular backplane management activities. SGPIO uses 3-bit
messages.
interrupts are enabled. This flag is cleared when the corresponding ISR is
executed.
Bit 5:1
These are reserved bits.
In the SPI Control Register (SPCR), the SPE bit is set to 1 to enable SPI
of AVR. To set the microcontroller as Master, the MSTR bit in the SPCR is
224 Serial Peripheral Interface (SPI)
also set to 1. To enable the SPI transfer/receive complete interrupt, the SPIE
is set to 1.
In case you don’t wish to use the SPI interrupt, do not set the SPIE bit to
1 and do not enable the global interrupts. This will make it look somewhat
like this:
// Initialize SPI Master Device (without interrupt)
void spi_init_master (void)
{
// Set MOSI, SCK as Output
DDRB = (1<<5) | (1<<3);
Master code:
SPI_Init:
sbi DDRB,DDB5 // Set MOSI as output
sbi DDRB,DDB7 // Set SCK as output.
sbi DDRB,DDB4 // Set SS’ as output.
ldi r16,01011101b // Set SPI as a Master, with interrupt disabled,
out SPCR,r16 // MSB first, SPI mode 3 and clock frequency
fosc/16.
SPI_Send:
ldi r16,0xAA
out SPDR,r16 // Initiate data transfer.
Wait:
sbis SPSR,SPIF // Wait for transmission to complete.
rjmp Wait
in SPDR,r16 // The received data is placed in r16.
6.9 Case Study 1: The SPI of the AVR 225
Slave code:
SPI_Init:
sbi DDRB,DDB6 // Set MISO as an output
ldi r16,01001100b // Set SPI as a Slave, with interrupt disabled,
out SPCR,r16 // MSB first and SPI mode 3.
ldi r16,0x55
out SPDR,r16 // Send 0x55 on Master request.
SPI_Receive:
sbis SPSR,SPIF
rjmp SPI_Receive // Wait for reception to complete.
in r16,SPDR // The received data is placed in r16.
For setting a microcontroller as a slave, one just needs to set the SPE Bit
in the SPCR to 1 and direct the MISO pin (PB4 in case of ATmega16A) as
OUTPUT.
The codes for sending and receiving data are same for both the slave as
well as the master. To send data, load the data into the SPI Data Register
226 Serial Peripheral Interface (SPI)
(SPDR), and then, wait until the SPIF flag is set. When the SPIF flag is set,
the data to be transmitted are already transmitted and are replaced by the
received data. So, simply return the value of the SPI Data Register (SPDR)
to receive data. We use the return type as unsigned char because it occupies 8
bits and its value is in the range 0–255.
6.9.3 Complete Application for using SPI of AVR
As application of using SPI of AVR, consider using SPI AVR to:
• send some data from Master to Slave.
• Slave in return sends an acknowledgement (ACK) data back to the
Master.
• Master should check for this ACK in order to confirm that the data
transmission has completed.
This is a typical example of full-duplex communication. While the Master
sends the data to the Slave, it receives the ACK from the Slave simultaneously.
The example and the related codes are part of AVR gallery.
Methodology
We would use the primary microcontroller (ATmega8 in this case) as the
Master device and a secondary microcontroller (ATmega16 in this case) as
the Slave device. A counter increments in the Master device, which is being
sent to the Slave device. The Master then checks whether the received data
are the same as ACK or not (ACK is set as 0x7E in this case). If the received
data are the same as ACK, it implies that data have been successfully sent and
received by the Master device. Thus, the Master blinks an LED connected to
it as many number of times as the value of the counter which was sent to the
Slave. If the Master does not receive the ACK correctly, it blinks the LED for
a very long time, thus notifying of a possible error.
On the other hand, Slave waits for data to be received from the Master.
As soon as data transmission begins (from Master to Slave, the Slave sends
ACK (which is 0x7E in this case) to the Master. The Slave then displays the
received data in an LCD.
Hardware Connections
Hardware connections are simple. Both the MOSI pins are connected
together, MISO pins are connected together and the SCK pins are also
connected together. The SS’ pin of the slave is grounded, whereas that of
the master is left unconnected. To demonstrate the operation of the slave and
6.9 Case Study 1: The SPI of the AVR 227
the interrupt, LCD and LED are connected. Figure 6.20 gives the complete
circuit diagram which is a standard for such example.
Full Code
The codes for the Master and Slave are given below. The codes are well
commented, so it should be easy to understand what is going on in the code.
The reader can also find the code in the AVR code gallery.
Master Code
#ifndef F_CPU
#define F_CPU 16000000UL
#endif
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
//Main
int main(void)
{
spi_init_master(); //Initialize SPI Master
DDRD | = 0x01; //PD0 as Output
while(1)
{
data = 0x00; //Reset ACK in "data"
data = spi_tranceiver(++x); //Send "x", receive ACK in "data"
if(data == ACK) { //Check condition
//If received data is the same as ACK, blink LED "x" number of
times
led_blink(x);
}
else {
//If received data is not ACK, then blink LED for a long time
so as to determine error
led_blink(LONG_TIME);
}
_delay_ms(\ref{GrindEQ__500_}); //Wait
}
6.10 Development Tools 229
Slave Code
#ifndef F_CPU
#define F_CPU 16000000UL
#endif
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "lcd.h"
int main(void)
{
lcd_init(LCD_DISP_ON_CURSOR_BLINK); //Initialize LCD
spi_init_slave(); //Initialize slave SPI
unsigned char data, buffer[10];
DDRA = 0x00; //Initialize PORTA as INPUT
PORTA = 0xFF; //Enable Pull-Up Resistors
while(1)
{
lcd_clrscr(); //LCD Clear screen
lcd_home(); //LCD move cursor to home
lcd_puts("Testing");
lcd_gotoxy(0,1);
data = spi_tranceiver(ACK); //Receive data, send ACK
itoa(data, buffer, 10); //Convert integer into
string
lcd_puts(buffer); //Display received data
_delay_ms(20); //Wait
}
}
Host adapters
There are a number of USB hardware solutions to provide computers, running
Linux, Mac, or Windows, SPI master, or slave capabilities. Many of them
also provide scripting or programming capabilities (Visual Basic, C/C++,
VHDL, etc.).
An SPI host adapter lets the user play the role of a master on an SPI
bus directly from a PC. They are used for embedded systems, chips (FPGA,
ASIC, and SoC) and peripheral testing, programming, and debugging.
The key parameters of SPI adapters are the maximum supported fre-
quency for the serial interface, command-to-command latency, and the
maximum length for SPI commands. It is possible to find SPI adapters on
the market today that support up to 100 MHz serial interfaces, with virtually
unlimited access length.
SPI protocol being a de facto standard, some SPI host adapters also have
the ability of supporting other protocols beyond the traditional 4-wire SPI
(e.g., support of quad-SPI protocol or other custom serial protocol that derive
from SPI).
Protocol analyzers
SPI protocol analyzers are tools which sample an SPI bus and decode the
electrical signals to provide a higher-level view of the data being transmitted
on a specific bus.
Oscilloscopes
Most oscilloscope vendors offer oscilloscope-based triggering and protocol
decoding for SPI. Most support 2-, 3-, and 4-wire SPI. The triggering and
decoding capability is typically offered as an optional extra. SPI signals can
be accessed via analog oscilloscope channels or with digital MSO channels.
Logic analyzers
When developing or troubleshooting the SPI bus, examination of hardware
signals can be very important. Logic analyzers are tools which collect, ana-
lyze, decode, and store signals, so people can view the high-speed waveforms
at their leisure. Logic analyzers display time-stamps of each signal level
change, which can help find protocol problems. Most logic analyzers have
6.11 Synchronous Serial Interface (SSI) 231
the capability to decode bus signals into high-level protocol data and show
ASCII data.
Background
Sensors for measuring linear or angular position are divided into two groups:
incremental and absolute. It is possible to identify the group for which
the sensor belongs by monitoring “What happens on power up?” If the
sensor has to do a calibration step to find its position – it’s incremental;
232 Serial Peripheral Interface (SPI)
other specifics such as electrical connectors, pins and wiring, are open to
the designer’s choice. The RS-422 circuit designs used by SSI allow data
to be reliably and quickly transmitted over long distances in noisy environ-
ments without expensive or bulky electronics, cables or connectors. High
data rates and long distances are achieved using balanced, or differential,
signaling. Differential means when one line is high, the other is low and
vice versa.
RS-422 uses a nominal 0 to 5 V signal levels and typically uses a cable
made of two sets of twisted pair wires (one pair for data and one pair for clock
signals) and a ground wire. While a double pair cable may be practical for
many RS-422 applications, the RS-422 specification only defines one signal
path and does not assign any function to it. Most SSI cable uses twisted
pairs with a metal foil or mesh, as an electromagnetic shield, over each
twisted pair and/or over the complete wire bundle underneath an overall cable
sheath.
Generally, with SSI, data and clock transmissions over cable lengths of
around 20 m need little or no special consideration. Distances of 20 m will
cover most position sensor applications. At cable lengths of >20 m, it’s a good
idea to keep cable lengths between position sensor and controller as short as
practical. High data rates of about 10 Mbits/second are readily achieved over
cable lengths of 10 or 20 m (with 24 AWG cable) but as cable lengths increase
above 20 m, sensor data rates should be reduced as per Figure 6.22:
The above data are based on 24 AWG wire and cable lengths can be
increased if the cable is beefed up to say 22 or 20AWG. Maximum cable
length is also influenced by the tolerable signal distortion, local electromag-
netic noise levels, and differences in ground potential between the cable
ends.
234 Serial Peripheral Interface (SPI)
the period Tmu – 0.5Xt. After Tmu, the latest position data are now available
for transmission in the next Read Cycle.
• T: Clock period (1/T = 100 kHz to 2 MHz)
• Trc: Read cycle time: This is defined as (n × T) + (0.5 × T)
• Tmu: Message update time. The time from last falling edge of clock to
when new data are ready for transmission
• Timg: Intermessage gap time. Must be >Tmu otherwise position data
will be indeterminate
• n: The number of bits in the message (not including the Error Flag).
• “tm” represents the transfer timeout (monoflop time). It is the minimum
time required by the slave to realize that the data transmission is com-
plete. After tm, the data line goes to idle and the slave starts updating its
data in the shift register.
• “tp” represents the pause time. It is the time delay between two
consecutive clock sequences from the master.
• “tw” represents the repetition time. It is the minimum time elapsed
between retransmissions of the same data and is always less than tm.
• “T” represents the width of each clock cycle. It is the time taken between
two falling or two rising edges in a continuous clock sequence.
• MSB: Most significant bit
• LSB: Least significant bit
Figure 6.23 illustrates the single data transmission using SSI protocol:
• The SSI is initially in the idle mode, where both the data and clock lines
stay HIGH and the slave keeps updating its current data.
• The transmission mode is evoked when the master initiates a train of
clock pulses. Once the slave receives the beginning of the clock signal
(1), it automatically freezes its current data. With the first rising edge (2)
of the clock sequence, the MSB of the sensor’s value is transmitted and
with consequent rising edges, the bits are sequentially transmitted to the
output.
6.11 Synchronous Serial Interface (SSI) 237
• After the transmission of complete data word (3) (i.e., LSB is transmit-
ted), an additional rising edge of the clock sets the clock line HIGH.
The data line is set to LOW and remains there for a period of time, tm,
to recognize the transfer timeout. If a clock signal (data-output request)
is received within that time, the same data will be transmitted again
(multiple transmission).
• The slave starts updating its value and the data line is set to HIGH (idle
mode) if there are no clock pulses within time, tm. This marks the end
of single transmission of the data word. Once the slave receives a clock
signal at a time, tp (=tm), the updated position value is frozen and the
transmission of the value begins as described earlier.
After n-CLOCK pulses (rising edges) the data is completely transmitted.
With the next CLOCK pulse (rising edge n+1) the sensor output goes to low
level which can be used to detect a short circuit in the cable. If it is high even
after n+1 rising edges then it means that the interface has a short circuit.
Readings from multiple slaves (up to three) can be enabled at the same
time by connecting them to a common clock. However, to avoid ground loops
and electrically isolate the slave, complete galvanic isolation by opto-couplers
is needed.
Multiple Transmission
Multiple transmissions of the same data from the position sensor happen
only if there is continuous clocking even after the transmission of the least
significant bit. The initial sequences are the same as that of the single
transmission. In the idle state, the CLOCK and DATA lines are high but
with the arrival of the first falling edge the transmission mode is evoked and
the similarly the data bits are transmitted sequentially starting with the most
significant bit with every rising edge of the CLOCK. The transmission of
the least significant bit means that the transmission of the data is complete.
An additional rising edge pushes the data line to low, signifying the end of
transmission of the data.
If there are continuous clock pulses even after the completion (i.e., the
next clock pulses comes in time tw [<tm]) the value of the slave is not
updated. This is because the monoflop output is still unsteady and the value
in the shift register still contains the same value as before. So with the next
rising edge, that is, after the (n+1) rising edge, the transmission of the same
data continues, and the MSB of data transmitted earlier is re-transmitted.
Then, it follows the same procedure as earlier transmissions, leading to
multiple transmissions of the same data. The value of the slave is updated
only when the timing between two clock pulses is more than the transfer
timeout. Multiple transmission can be used to check the data integrity. The
two consecutive received values are compared, and transmission failures are
indicated by differences between the two values. The transmission of data is
controlled by the master and the transmission can be interrupted at any time
just by stopping the clock sequence, for a period longer than the time out
6.11 Synchronous Serial Interface (SSI) 239
period. The slave automatically will recognize the transfer timeout and go
into idle mode.
Some position sensor manufacturers have added additional information to
the basic SSI protocol, in various efforts to ensure high integrity data trans-
mission. For secure transmission and to indicate the end of data transmission
CRC bits or parity bits can be added. They are used for identifying if the data
from the position sensor has been correctly interpreted and received.
Multiple transmission is used to check the data integrity. The two consec-
utive received values are compared, and transmission failures are indicated
by differences between the two values.
Interrupting transmission
The transmission of data is controlled by the master and the transmission can
be interrupted at any time just by stopping the clock sequence, for a period
longer than tm. The slave automatically will recognize the transfer timeout
and go into idle mode.
increases. The AC effects of the cable limit the quality of the signal and limit
the cable length to short distances when high data rates are used. Examples
of data rate and cable length combinations vary from 90 kbit/s at 1.2 km to
10 Mbit/s at 5 m for RS-422.
Cables having characteristics different from the twisted pair 24 AWG,
52.5 pF/m (16 pF/ft) can also be employed within bounds mentioned above.
First, determine the absolute loop resistance and capacitance values of the
typical 24 AWG cable provided by the cable length associated with the data
signaling rate desired from the figure. Then convert those values to equivalent
lengths of the cable actually used. For example, longer distances would be
6.11 Synchronous Serial Interface (SSI) 241
Minimal Delay
The timing diagram below shows an SSI system with very little delay. On the
first rising edge of the Clock, the SSI device puts the first bit of data on the
Data line. By the next rising edge of the Clock, when the RMC samples the
data, the data is valid, and the read is successful.
Excessive Delay
The timing diagram below shows an SSI system with a time delay of more
than one clock period. On the first rising edge of the Clock, the SSI device
puts the first bit of data on the Data line. By the next rising edge of the Clock,
when the RMC samples the data, the data from the SSI device have not yet
arrived, and the SSI input will not return the correct value.
To compensate for the delay, set SSI Wire Delay parameter. You can enter
the wire length or enter the time delay directly. The SSI input will then use
the delay value to correctly read the SSI input data.
their traditional counterparts and so, unsurprisingly they are just as reliable
and robust but are more accurate and easier to use. Their ease of use partly
comes from the fact that they use SSI as a preferred communication method.
They have gained a significant market share in through bore, bearing-less for-
mats favored in high reliability, precision sensor applications in the defense,
medical, aerospace and industrial sectors.
6.11.7 Benefits
• Serial data transfer has reduced the wiring. This, in addition to the sim-
plicity of SSI design due to use of minimal number of components, has
considerably reduced the cost and created more transmission bandwidth
for message bits.
• High Electromagnetic interference immunity due to RS-422 standards
and higher reliability of data transmission due to differential signaling.
• Optimal galvanic isolation
• Complete protocol flexibility for the number of bits transferred. Not
limited to a certain number of words and has an arbitrary choice of
message size.
• Slaves use master’s clock and hence don’t need precision oscillators.
• The SSI allows to connect up to three slaves to a common clock.
Therefore, it is possible to attain values from multiple sensors.
The limitations in this interface are negligible for applications in indus-
trial automation. SSI can handle only short distance communication (up to
1.2 km) and supports only one master device. But, 1.2 km is rather a good
distance for communication by automation industry standards. When com-
pared to advanced communication systems based on field buses or Ethernet,
244 Serial Peripheral Interface (SPI)
References
Web Sources
[1] SPI Block Guide v3.06; Motorola/Freescale/NXP; 2003.
[2] “N5391B I2 C and SPI Protocol Triggering and Decode for Infiniium
scopes”.
[3] MICROWIRE Serial Interface National Semiconductor Application
Note AN-452
[4] MICROWIRE/PLUS Serial Interface for COP800 Family National
Semiconductor Application Note AN-579
[5] “QuadSPI flash: Quad SPI mode vs. QPI mode”. NXP community
forums. December 2014. Retrieved 2016-02-10.
[6] Patterson, David (May 2012). “Quad Serial Peripheral Interface (Quad-
SPI) Module Updates” (PDF) (Application note). Freescale Semicon-
ductor. Retrieved September 21, 2016.
[7] Pell, Rich (13 October 2011). “Improving performance using SPI-DDR
NOR flash memory”. EDN.
[8] Enhanced Serial Peripheral Interface (eSPI) Interface Base Specification
(for Client and Server Platforms) (PDF) (Report). Revision 1.0. Intel.
January 2016. Document number 327432-004. Retrieved 2017-02-05.
[9] Enhanced Serial Peripheral Interface (eSPI) Interface Specification
(for Client Platforms) (PDF) (Report). Revision 0.6. Intel. May 2012.
Document Number 327432-001EN. Retrieved 2017-02-05.
7
Universal Serial Bus (USB)
245
246 Universal Serial Bus (USB)
peripherals like keyboards, pointing devices, digital still and video cameras,
printers, mice, scanners, portable media players, disk drivers and network
adapters to personal computers, both to communicate and to supply electric
power. This means that while USB provides a sufficiently fast serial data
transfer mechanism for data communications, it is also possible to obtain
power through the connector making it possible to power small devices via
the connector and this makes it even more convenient to use, especially
‘on-the-go.’
It was important while developing USB to be sure that no special user-
knowledge would be required to install a new device, and all devices would
be distinguishable from all other devices, such that the correct driver software
was always automatically used.
The USB specification allows for the connection of a maximum of 127
peripheral devices (including hubs) to the system, either on the same port or
on different ports.
USB also supports Plug and Play installation and hot swapping. The USB
1.1 standard supports both isochronous and asynchronous data transfers and
has dual speed data transfer: 1.5 Mb/s (megabits per second) for low-speed
USB devices and 12 Mb/s for full-speed USB devices (much faster than the
original serial port). Cables connecting the device to the PC can be up to 5 m
(16.4 ft) long. USB includes built-in power distribution for low power devices
and can provide limited power (up to 500 mA of current) to devices attached
on the bus.
The USB 2.0 standard supports a signalling rate of 480 Mb/s, known as
“high speed,” which is 40 times faster than the USB 1.1 full-speed transfer
rate.
USB 2.0 is fully forward- and backward-compatible with USB 1.1 and
uses existing cables and connectors.USB 2.0 supports connections with PC
peripherals that provide expanded functionality and require wider bandwidth.
In addition, it can handle a larger number of peripherals simultaneously.
USB 2.0 enhances the user’s experience of many applications, including
interactive gaming, broadband Internet access, desktop, and Web publishing,
Internet services and conferencing.
The Universal Serial Bus provides a very simple and effective means of
providing connectivity, and as a result, it is very widely used. USB provides
several benefits compared to other communication interfaces such as ease of
use, low cost, low power consumption and, fast and reliable data transfer.
7.1 Introduction to USB 247
There are however converter modules and cables that can be successfully
used to connect RS-232 devices to computers via a USB port. Such convertors
are discussed latter
had miniature connectors as though they had a tethered connection (that is:
no plug or receptacle at the peripheral end). There was no known miniature
type A connector until USB 2.0 (revision 1.01) introduced one.
Table 7.1 Performance figures for USB 3.0 and USB 3.1
Performance figures for USB 3.0 and USB 3.1
USB Version Duplex Status Transfer Speed Increase Over USB 2.0
USB 2.0 Half Duplex 480 Mbps –
USB 3.0 – SuperSpeed Full Duplex 5 Gbps 10 x
USB 3.1 – SuperSpeed+ Full Duplex 10 Gbps 20 x
operation over existing wires that were intended for flip-flop capabilities of
the Type-C connector.
The bus power capability has also been increased to 900mA. This is an
80% increase over USB 2.0 which stood at 500mA.
USB 3, both as 3.0 and 3.1, is able to provide the data transfer speeds
required for many applications for which USB connections are used. The
speed increase is partially important in areas like data backups for PCs where
the increased levels of data mean that the higher speeds of USB 3.0 and
USB 3.1 are welcomed. The speed improvements are also felt in many other
areas where large amounts of data need to be transferred rapidly over a USB
interface.
The standard USB connector used on items like flash memory cards and
many computer connections of the Type-A, and there are other types as well
that are used for camera connectors, smartphones and the like, but the type-A
connector has remained the same for very many years.
Low Speed
This was intended for cheap, low data rate devices like mice. The low speed
captive cable is thinner and more flexible than that required for full and high
speed.
• Low-speed devices:
– Examples: keyboards, mice, and game peripherals
– Bus Rate: 1.5 Mb/s
– Maximum Effective Data Rate: 800 B/s
Full Speed
This was originally specified for all other devices.
• Full-speed devices
– Examples: phones, audio devices, and compressed video
– Bus rate: 12 Mb/s
– Maximum effective data rate: 1.2 Mb/s
High Speed
The high speed additions to the specification were introduced in USB 2.0 as
a response to the higher speed of Firewire.
• Hi-speed devices
– Examples: video, imaging, and storage devices
– Bus Rate: 480 Mb/s
– Maximum Effective Data Rate: 53 Mb/s
7.3 USB Data Speeds 259
bus access, performing error checking, providing and managing power, and
exchanging data with the devices.
All communications on USB bus are initiated by the host: slaves (USB
devices) cannot communicate directly.
A device cannot initiate a transfer, but must wait to be asked to transfer
data by the host. The only exception to this is when a device has been put
into “suspend” (a low power state) by the host then the device can signal a
“remote wakeup.”
7.4.1.2 Types of host controller
The USB host controllers have their own specifications. There are three
commonly encountered types of USB host controller, each with its own
history and characteristics.
With USB 1.1, there were two Host Controller Interface Specifications:
• UHCI (Universal Host Controller Interface)
• OHCI (Open Host Controller Interface)
7.4.1.4 On-The-Go
An extension to the USB specification has been defined, to allow a device to
also become a limited role host. This specification is known as On-The-Go.
Section 7.6 covers this specification in detail.
The limit for USB 1.0/1.1 cable length is 3 m (about 9 ft and 10 inches) and
the maximum total length should not exceed 18 m (about 59 ft).
Note: For more technical information see:
USB 2.0 Specification
USB 3.0/USB 3.1 Specifications
hand is a D− greater than 2.8 V and a D+ less than 0.3 V with the same
appropriate pull down/up resistors.
The receiver defines a differential ‘1’ as D+ 200 mV greater than D- and
a differential ‘0’ as D+ 200 mV less than D−. The polarity of the signal is
inverted depending on the speed of the bus. Therefore, the terms ‘J’ and ‘K’
states are used in signifying the logic levels. In low speed, a ‘J’ state is a
differential 0. In high speed, a ‘J’ state is a differential 1.
USB transceivers will have both differential and single ended outputs.
Certain bus states are indicated by single ended signals on D+, D- or both.
For example, a single ended zero or SE0 can be used to signify a device reset
if held for more than 10 mS. A SE0 is generated by holding both D− and D+
low (<0.3 V). Single ended and differential outputs are important to note if
you are using a transceiver and FPGA as your USB device. You cannot get
away with sampling just the differential output.
The low speed/full speed bus has a characteristic impedance of 90 ohms
± 15%. It is therefore important to observe the datasheet when selecting
impedance matching series resistors for D+ and D−. Any good datasheet
should specify these values and tolerances.
High speed (480 Mbits/s) mode uses a 17.78 mA constant current for
signalling to reduce noise.
7.6.1.1 Cable types
The USB specification defines three forms of cable:
1. A high-/full-speed detachable cable with one end terminated with an A
plug and the other end with a B or mini-B plug.
2. A captive high-/full-speed cable where one end is either hardwired to the
vendor’s equipment or connected via a vendor specific connector and the
other end is terminated with an A plug.
3. A low speed version of 2.
The maximum length of a high-/full-speed cable is determined by the
attenuation and propagation delay. But, for a low speed cable, it is the
signal rise and fall times that determine the maximum length. This forces
the maximum length for low-speed cable to be shorter than that for high/full
speed.
facing device (Hub or Host) must support all three modes, high speed, full
speed, and low speed.
Device Powering
When it comes to USB power, there are two device categories: bus powered
and self-powered. One of the benefits of USB is bus-powered devices, devices
which obtain its power from the bus and require no external plug packs or
additional cables. This benefit is due to the availability of the 5 V supply.
However, before designing a bus-powered device it is well to consider the
limitations of this approach. For example, the voltage supplied can fall to
4.35 V at the device. There can also be transients on this taking it 0.4 V
lower, due to other devices being plugged in. Any device connected to the
USB bus needs to cope with these voltage levels.
The standard unit load available, as mentioned before, is 100 mA. No
device is permitted to take more than this before it has been configured by
the host. It must also reduce its current consumption to 2.5 mA whenever it
is ‘suspended’ by a lack of activity on the bus. However, it is not required to
obey this rule for a period of 1 s from when it connects. (Note: ECN removed
the need to suspend during the first second after connect.)
It should be remember that of this 2.5 mA, the required 1.5 k pull-up
resistor is already drawing 0.3 mA. This leaves the designer a budget of
272 Universal Serial Bus (USB)
2.2 mA to power the rest of his device circuitry. If the device contains a
microcontroller it will need a sleep mode which meets this requirement, but
it is important to take into consideration the fact that a badly placed resistor
can very easily draw current which the designer hadn’t expected. It is impor-
tant, to avoid this unexpected matter, to measure the suspend current with
a meter.
The voltage supplied can fall to 4.35 V at the device. There can also be
transients on this taking it 0.4 V lower, due to other devices being plugged
in. Any device connected to the USB bus needs to cope with these voltage
levels.
A USB device specifies its power consumption expressed in 2 mA units
in the configuration descriptor which will discussed and examined in detail
later. A device cannot increase its power consumption, greater than what it
specifies during enumeration, even if it looses external power. There are three
classes of USB functions:
• Low-power bus powered functions
• High-power bus powered functions
• Self-powered functions
Low-power bus powered functions draw all its power from the VBU S and
cannot draw any more than one unit load. Low power bus powered functions
must also be designed to work down to a VBU S voltage of 4.40 V and up to a
maximum voltage of 5.25 V measured at the upsteam plug of the device. For
many 3.3 V devices, LDO regulators are mandatory.
High-powered Devices: High-power bus powered device will draw all its
power from the bus and cannot draw more than one unit load until it has been
configured. After configuring the device as a high-power device, it may draw
up to 500 mA, provided it asked for this in its descriptor. Being configured
is dependent on the Hub being able to supply 500 mA, which implies a self-
powered hub. So there is always a degree of uncertainty whether more than
100 mA will be available. It would be well to offer the option of external
power via a socket on such a device.
High-power bus functions must be able to be detected and itemized at a
minimum 4.40 V. When operating at a full unit load, a minimum VBUS of 4.75
V is specified with a maximum of 5.25 V. Once again, these measurements
are taken at the upstream plug.
Self-powered Devices: Devices requiring more than 500 mA are obliged to
be self-powered. Self-powered devices may draw up to 1 unit load from
7.6 USB HARDWARE 273
the bus and derive the rest of its power from an external source. Should
this external source fail, it must have provisions in place to draw no more
than 1 unit load from the bus. Self-powered devices are easier to design to
specification as there is not so much of an issue with power consumption.
The 1 unit bus powered load allows the detection and enumeration of devices
without mains/secondary power applied.
The practice of attempting to draw power from two adjacent USB ports,
using a modified cable, is not permitted and can easily damage the ports.
When designing a self-powered device, the designer has to remember that
he must not pull a D+ or D- line above the Vbus voltage supplied. This means
that he must, at the very least, sense when Vbus is connected.
The D+ or D− resistor should, strictly speaking, be pulled up to a 3.3
V supply derived from Vbus, or controlled by Vbus in such a way that the
resistor never sources current to the data line when Vbus is switched off.
If the designer pulls, say D+, high in the absence of VBUS then he will
risk faulty operation with On-The-Go hosts. (See later).
No USB device, whether bus powered or self- powered can drive the
VBUS on its upstream facing port. If VBUS is lost, the device has a lengthy
10 s to remove power from the D+/D- pull-up resistors used for speed
identification.
Hot – Pluggable: To achieve the goal of being able to plug a device into and
out of a running system, some design rules must be followed to handle the
“Inrush Current”. Inrush current is the result of the capacitance added to the
bus as a result of connecting a device between VBUS and ground. The spec
therefore specifies that the maximum decoupling capacitance the designer can
have on the device is 10 uF. When the designer disconnects the device after
current is flowing through the inductive USB cable, a large flyback voltage
can occur on the open end of the cable. To prevent this, a 1 uF minimum
VBUS decoupling capacitance is specified.
Another factor to be considered is that when the user plugs a device in,
any capacitance between Vbus and GND will cause a dip in voltage across
the other ports of the hub to which the device is connecting. To limit the
consequences of this (such as crashing other devices), the specification places
a maximum on the value of capacitance across Vbus and GND of 10 uF. For
the same reason, the hub port supply must be bypassed with at least 120 uF.
For the typical bus powered device, it cannot drain any more than 500 mA
which is not unreasonable. If the current increases this limit the device will
entre to the “Suspend Mode”
274 Universal Serial Bus (USB)
series with the 1.5 k ohm pull up, making a total load of 16.5 k ohms on a
VTERM of typically 3.3 V. Therefore this resistor sinks 200 uA before we
even start.
Another consideration for many devices is the 3.3 V regulator. Many of
the USB devices run on 3.3 V. The PDIUSBD11 is one such example. Linear
regulators are typically quite inefficient with average quiescent currents in the
order of 600 uA, and therefore, more efficient and thus expensive regulators
are called for. In the majority of cases, the designer must also slow down or
stop clocks on microcontrollers to fall within the 500 uA limit.
Exceeding the 500 uA limitation may cause some complications. The
complications of exceeding the specified limits is coming from the fact that
most hosts and hubs don’t have the ability to detect such an overload of this
magnitude, and thus if the device drain maybe 5 mA or even 10 mA, the
system will not detect that and it should still be fine, in spite of the fact that the
device violates the USB specification. However in normal operation, if you
try to exceed the 100 mA or your designated permissible load, then expect
the hub or host to detect this and disconnect your device, in the interest of the
integrity of the bus.
Of course these design issues can be avoided if the user chooses to design
a self- powered device. Suspend currents may not be a great concern for desk-
top computers but with the introduction of the On-The-Go Specification we
will start seeing USB hosts built into mobile phones and mobile organizers.
The power consumption pulled from these devices will adversely affect the
operating life of the battery.
• A low speed bus will have a keep alive which is an EOP (End of Packet)
every 1 ms only in the absence of any low speed data.
The term “Global Suspend” is used when the entire USB bus enters
suspend mode collectively. However, selected devices can be suspended by
sending a command to the hub that the device is connected too. This is
referred to as a “Selective Suspend.”
The device will resume operation when it receives any non-idle signalling.
If a device has remote wakeup enabled then it may signal to the host to resume
from suspend.
The DB9 and DB25 connectors which are used for RS-232 ports and parallel
ports on computers often have problems with connection bolts falling out of
the computer case if someone has accidentally tightened the screws of the
connector too far. People who have often disconnected and reconnected their
VGA cable might have experienced that these densely populated connectors
have very thin pins which bend easily.
Another problem with bad connector design is that you may accidentally
connect them wrong. This is something which can happen, for example, with
flat cable connectors and power connectors inside computers. As USB can
power devices over the cable it is not only necessary that a USB connector
cannot be connected in the wrong orientation, but the design must also not
allow that two power providing USB devices are connected with each other
as this may cause one or both power supplies to be damaged.
on computer main boards and hubs. Type B plugs are always connected
downstream, and consequently, type B sockets are found on devices.
It is interesting to find type A to type A cables wired straight through
and an array of USB gender changers in some computer stores. This is in
280 Universal Serial Bus (USB)
contradiction of the USB specification. The only type A plug to type A plug
devices are bridges which are used to connect two computers together. Other
prohibited cables are USB extensions which has a plug on one end (either
type A or type B) and a socket on the other. These cables violate the cable
length requirements of USB.
Because most small devices which can both act as a master and a slave
only have one USB connector, additions to the connector definition were
necessary to allow a role change with only one type of cable. This is where
the mini-USB AB and later the micro-USB AB connector are defined for.
The mini-USB AB connector is now officially deprecated, but the micro-
USB AB connector is replacing its place rapidly. Countries like China are
even considering to make this micro-USB AB connector mandatory on all
new cell phones sold. In this micro-USB AB connector, the ID pin is used to
signal the master of slave function.
Micro-USB connectors. The only difference is that for the micro-USB
AB connector the ID pin now has a function assigned to it.
8
USB Data Flow
8.1 Introduction
This chapter is continuation of our discussions on USB. The chapter concen-
trates on Data Flow in USB Devices. To give enough idea for the reader about
this subject, the chapter introduces the following topics: USB Data Exchange,
USB Data Transfer Types, USB Data Flow Model, USB On-the-Go (OTG),
USB Class Devices, USB Enumeration, Device Drivers, USB Descriptors and
the chapter ends by discussing RS-232 to USB converters.
Transceivers
At each end of the data link between host and device is a transceiver circuit.
The transceivers are similar, differing mainly in the associated resistors.
283
284 USB Data Flow
When receiving, individual receivers on each line are able to detect single
ended signals, so that the so-called Single Ended Zero (SE0) condition, where
both lines are low, can be detected. There is also a differential receiver for
reliable reception of data.
The host can determine the required speed by observing which line is
pulled high.
in. The ‘1’ level will be on D− for a low speed device, and D+ for a full (or
high) speed device.
Idle: The state of the data lines when the pulled up line is high, and the other
line is low, is called the idle state. This is the state of the lines before and after
a packet is sent.
288 USB Data Flow
J, K and SEO States: To make it easier to talk about the states of the data
lines, some special terminology is used. The ‘J State’ is the same polarity as
the idle state (the line with the pull-up resistor is high, and the other line is
low), but is being driven to that state by either host or device. The K state is
just the opposite polarity to the J state. The Single Ended Zero (SE0) is when
both lines are being pulled low. The J and K terms are used because for Full
Speed and Low Speed links they are actually of opposite polarity.
Single Ended One (SE1): This is the illegal condition where both lines are
high. It should never occur on a properly functioning link.
Reset: When the host wants to start communicating with a device it will
start by applying a ’Reset’ condition which sets the device to its default
8.1 Introduction 289
unconfigured state. The Reset condition (Figure 8.6) involves the host pulling
down both data lines to low levels (SE0) for at least 10 ms. The device may
recognize the reset condition after 2.5 µs. This ’Reset’ should not be confused
with a micro-controller power-on type reset. It is a USB protocol reset to
ensure that the device USB signaling starts from a known state.
EOP signal: The End of Packet (EOP) is an SE0 state for 2 bit times,
followed by a J state for 1 bit time (Figure 8.7).
Suspend: One of the features of USB which is an essential part of today’s
emphasis of ’green’ products is its ability to power down an unused device. It
does this by suspending the device, which is achieved by not sending anything
to the device for 3 ms. Normally a SOF packet (at full speed) or a Keep Alive
signal (at low speed) is sent by the host every 1 ms, and this is what keeps
the device awake. A suspended device may draw no more than 0.5 mA from
290 USB Data Flow
Vbus . A suspended device must recognize the resume signal, and also the
reset signal.
Note: If a device is configured for high power (up to 500 mA), and has its
remote wakeup feature enabled, it is allowed to draw up to 2.5 mA during
suspend.
Resume: When the host wants to wake the device up after a suspend, it does
so by reversing the polarity of the signal on the data lines for at least 20 ms.
The signal is completed with a low speed end of packet signal (Figure 8.9).
It is also possible for a device with its remote wakeup feature set, to initiate
a resume itself. It must have been in the idle state for at least 5 ms, and must
apply the wakeup K condition for between 1 and 15 ms. The host takes over
the driving of the resume signal within 1 ms.
Keep Alive Signal: This is represented by a Low speed EOP. It is sent at least
once every millisecond on a low speed link, in order to keep the device from
suspending.
8.1 Introduction 291
Figure 8.12 The PID is shown here in the order of transmission, LSB first.
of the specification, and the circuitry grouping which performs this function
is referred to as the Serial Interface Engine (SIE).
There are 17 different PID values defined. This includes one reserved
value, and one value which has been used twice with different meanings for
two different situations.
Notice that the first 2 bits of a token which are transmitted, determine
which of the 4 groups it falls into. This is why SOF is officially considered to
be a token PID.
There are four different packet formats based on which PID the packet
starts with.
Token Packet
The Token Packet, Figure 8.13, is used for SETUP, OUT and IN packets.
They are always the first packet in a transaction, identifying the targeted
294 USB Data Flow
endpoint, and the purpose of the transaction. The token packet contains two
addressing elements:
• Address (7 bits): This device address can address up to 127 devices.
Address 0 is reserved for a device which has not yet had its address set.
• Endpoint number (4 bits): There can be up to 16 possible endpoints in a
device in each direction. The direction is implicit in the PID. OUT and
SETUP PIDs will refer to the OUT endpoint, and an IN PID will refer
to the IN endpoint
The SOF packet is also defined as a Token packet, but has a slightly
different format and purpose, which is described below.
Data Packet
Data packet format is given in Figure 8.14.
Handshake packet, Figure 8.15, is used for ACK, NAK, STALL and NYET
packets. This is the packet format used in the status stage of a transaction,
when required.
8.1 Introduction 295
8.1.6 Transactions
A successful transaction is a sequence of three packets which performs a
simple but secure transfer of data.
For IN and OUT transactions used for isochronous transfers, there are
only 2 packets; the handshake packet on the end is omitted. This is because
error-checking is not required.
There are three types of transaction. In each of the illustrations below, the
packets from the host are shaded, and the packets from the device are not, as
shown below:
OUT Transaction
A successful OUT transaction, Figure 8.17, comprises two or three sequential
packets. If it were being used in an Isochronous Transfer there would not be
a handshake packet from the device.
296 USB Data Flow
On a low or full speed link, the PID shown as DATAx will be either a
DATA0 or a DATA1. An alternating.
IN Transaction
A successful IN transaction, Figure 8.18, comprises two or three sequential
packets. If it were being used in an Isochronous Transfer there would not be
a handshake packet from the host.
Here again, the DATAx is either a DATA0 or a DATA1.
SETUP Transaction
A successful SETUP transaction comprises three sequential packets. This is
similar to an OUT transaction, but the data payload is exactly 8 bytes long,
and the SETUP PID in the token packet informs the device that this is the first
transaction in a Control Transfer (see Figure 8.19).
As will be seen below, the SETUP transaction always uses a DATA0 to
start the data packet.
Data can be transferred between the host and only one device at a time
(peer to peer communication). However, two hosts cannot communicate
directly, nor can two USB devices (with the exception of On-The-Go (OTG)
devices, where one device acts as the master (host) and the other as the slave.)
The data on the USB bus is transferred via pipes that run between software
memory buffers on the host and endpoints on the device.
Data flow on the USB bus is half duplex, that is, data can be transmitted
only in one direction at a given time.
USB Pipes
A pipe is a logical component that represents an association between an
endpoint on the USB device and software on the host. Data is moved to and
from a device through a pipe. A USB pipe is associated to a unique endpoint
address, type of transfer, maximum packet size, and interval for transfer. The
298 USB Data Flow
USB specifications define two types of pipes based on the type of data transfer
used in the pipe (communication mode):
• Stream Pipes: handle interrupt, bulk and isochronous transfers. Data
carried over the pipe is unstructured.
• Message Pipes support the control transfer type. Data carried over the
pipe has a defined structure.
USB Endpoints
An endpoint (or endpoint function), Figure 8.21, is a uniquely identifiable
(addressable) entity on a USB device, which is the source or terminus of the
data that flows from or to the device. Each USB device, logical or physical,
has a collection of independent endpoints. The three USB speeds (low, full,
and high) all support one bidirectional control endpoint (endpoint zero) and
15 unidirectional endpoints. Each unidirectional endpoint can be used for
either inbound or outbound transfers, so theoretically there are 30 supported
endpoints.
Each endpoint is identified using an endpoint address. The endpoint
address of a device is fixed, and is assigned when the device is designed, as
opposed to the device address, which is assigned by the host dynamically
during enumeration. An endpoint address consists of an endpoint number
field (0 to 15), and a direction bit that indicates if the endpoint sends data
to the host (IN) or receives data from the host (OUT). The maximum number
of endpoints allowed on a single device is 32.
Each endpoint has the following configurable attributes that define the
behavior of a USB device:
• Bus access frequency requirements
• Bandwidth requirement
• Error handling mechanism
• Maximum packet size that the endpoint is able to send or receive
• Transfer type
• Direction in which data is sent and receive from the host
The USB Enumeration and Configuration section (Section 8.8) describes
a step in which the device responds to the default address. This occurs before
other descriptor information such as the endpoint descriptors are read by the
host later in the enumeration process. During this enumeration sequence, a
special set of endpoints are used for communication with the device. These
special endpoints, collectively known as the Control Endpoint or Endpoint 0,
are defined as Endpoint 0 IN and Endpoint 0 OUT. Even though Endpoint
8.2 Data Flow in USB Devices: Pipes and Endpoints 299
0 IN and Endpoint 0 OUT are two endpoints, they look and act like one
endpoint to the developer. Every USB device must support Endpoint 0. For
this reason, Endpoint 0 does not require a separate descriptor.
variable times where the transfers can use any available bandwidth space.
They are the most common transfer type for USB devices. Delivery time
with a bulk transfer is variable because there is no set aside bandwidth for
the transfer. The delivery time varies depending on how much bandwidth on
the bus is available, which makes the actual delivery time unpredictable. Bulk
transfers give guaranteed accuracy because errors are properly detected and
transactions are resent. Bulk transfers are useful in moving large amounts of
data that are not time sensitive.
In case of bulk endpoint, the maximum packet size is a function of device
speed. High-speed capable devices support a maximum BULK packet size
of 512 bytes. Full-speed capable devices support a maximum packet size of
64-bytes. Low-speed devices do not support bulk transfer types.
Isochronous Endpoints: These endpoints support isochronous transfers,
which are continuous, real-time transfers that have a pre-negotiated band-
width. Isochronous transfers must support streams of error tolerant data
because they do not have an error recovery mechanism or handshaking. Errors
are detected through the CRC field, but not corrected. With isochronous,
arises tradeoff of guaranteed delivery versus guaranteed accuracy. Streaming
music or video are examples of an application that uses isochronous endpoints
because the occasional missed data is ignored by the human ears and eyes.
Isochronous transfers have a guaranteed bandwidth of 90% on Low- and
Full-speed devices (80% on High-speed devices) that is shared with interrupt
endpoints.
High-speed capable devices support a maximum packet size of 1024
bytes. Full-speed devices support a maximum packet size of 1023 bytes. Low-
speed devices do not support isochronous transfer types. There are special
considerations with isochronous transfers. It is required to have 3x buffering
to ensure data is ready. The three buffers are: one actively transmitting buffer,
another buffer loaded and ready to transfer, and a third buffer being actively
loaded.
Maximum Transfer 832 KB/s 1.216 MB/s 1.216 MB/s 1.023 MB/s
Speed
[1] Shared bandwidth between isochronous and interrupt.
The USB specification provides for the following data transfer types.
Figure 8.22 USB Read and Write (taken from the USB specification).
“(in)” indicates data flow from the device to the host.
“(out)” indicates data flow from the host to the device.
Control transfers are used for initial configuration of the device by the
host, using Endpoint 0 OUT and Endpoint 0 IN, which are reserved for this
purpose. They may be used (on the same endpoints) after configuration as
part of the device-specific control protocol, if required.
The maximum packet size for control endpoints can be only 8 bytes for
low-speed devices; 8, 16, 32, or 64 bytes for full-speed devices; and only 64
bytes for high-speed devices.
Figure 8.24 shows the setup stage. Notice that it is not permitted for a
device to respond to a SETUP with a NAK or a STALL.
306 USB Data Flow
DATA STAGE
(same as for bulk transfer)
STATUS STAGE
(same as for bulk transfer)
• Typically the host will only fetch one packet, at an interval specified
in the endpoint descriptor (see below). The host guarantees to perform
the IN transaction at least that often, but it may actually do it more
frequently.
• The maximum packet size for interrupt endpoints can be 8 bytes or less
for low-speed devices; 64 bytes or less for full-speed devices; and 1,024
bytes or less for high-speed devices.
• Interrupt transfer is normally used when it is needed to be regularly kept
up to date of any changes of status in a device. Examples of their use are
for a mouse or a keyboard.
Error control is very similar to that for bulk transfers.
Figure 8.27 is an example of Interrupt transfer. Figure 8.28 shows the
Error control flow.
Error Control – IN
• If the IN token packet is not recognized, the device will not respond at
all. Otherwise, if it has data to send it will send it in a DATA0 or DATA1
310 USB Data Flow
packet, if it is not ready to send data it will send a NAK packet. If the
endpoint is currently ’halted’ then it will respond with a STALL packet.
• In the case of DATA0/1 being sent, the host will acknowledge with an
ACK, unless the data is not validly received, in which case it does not
send an ACK. (Note: the host never sends NAK!)
Transfer Completion
The notion of transfer completion is only relevant for control, bulk and inter-
rupt transfers as isochronous transfers occur continuously and periodically by
nature. In general, control, bulk and interrupt endpoints must transmit data
payload sizes that are less than or equal to the endpoint’s maximum data
payload size. When a transfer’s data payload is greater than the maximum
data payload size, the transfer is split into several transactions whose payload
is maximum-sized except the last transaction which contains the remaining
data. A transfer is deemed complete when:
• The endpoint transfers exactly the amount of data expected.
• The endpoint transfers a short packet that is a packet with a payload size
less than the maximum.
• The endpoint transfers a zero-length packet.
312 USB Data Flow
Introduction
The USB specification, as mentioned before, introduced a simple and inex-
pensive infrastructure for easily connecting multiple external peripherals to
a PC. That was several years ago; today, more than 500 million peripheral
devices are designed with USB ports, making USB the market’s dominant
I/O-connectivity standard. The widespread availability of USB peripherals is
now driving non-PC applications, such as mobile, handheld, and embedded
post-PC applications, to adopt USB for direct-I/O connections. In addition,
many devices that have traditionally functioned as peripherals now require
direct connections to other devices. USB’s greatest limitation – its lack of
support for point-to-point communication between devices – has deterred
its use in consumer-electronic devices, such as mobile phones and PDAs.
However, these devices are gaining popularity and intelligence, increasing the
need for direct connections among them. The answer to this requirement is in
a developing standard called USB OTG (USB On-The-Go), a supplement to
the USB specification that eliminates the requirement for a PC to act as host
in exchanges of data among connected devices.
The OTG specification’s goal is to enhance certain USB peripherals
to enable them to also act as hosts for a selected set of peripherals.
OTG introduces point-to-point communication between these enhanced USB
peripherals. USB On-the-Go (OTG) allows two USB devices to talk to each
other without requiring the services of a personal computer. Although OTG
appears to add \“peer to peer\” connections to USB, it does not. Instead,
USB OTG retains the standard USB host/peripheral model, where a single
host talks to USB peripherals. OTG introduces the dual-role device (DRD),
capable of functioning as either host or peripheral. Part of the magic of OTG
is that a host and peripheral can exchange roles if necessary.
This tends to maintain the current USB host/peripheral architecture
model. The OTG host always initiates communication with a normal
bus-enumeration process (bus reset, acquisition of USB descriptors, and
peripheral-device configuration (see Section 8.8). After these steps, the device
serving as OTG host may transfer data to and from an OTG device performing
as a peripheral. The OTG specification defines a mechanism for exchanging
the roles of OTG host and peripheral. The initial role of each device is defined
by which mini-plug a user inserts into its receptacle.
8.6 USB On-the-Go (OTG): Uses and Support 313
How to be a Host
The Figure 8.32 circuit functions only as a USB peripheral device. To add
OTG dual-role capability, the transceiver must be augmented to allow the
OTG device to function as either host or peripheral. Adding the following to
Figure 1 lets the system also function as a host:
• 15 kΩ pull-down resistors on D+ and D−
• A means to supply, rather than draw, power on VBUS
The ASIC or controller must also contain logic to function as a USB host.
Some of the host duties absent in a peripheral device are:
• Send SOF (Start of Frame) packets.
• Send SETUP, IN, and OUT packets.
• Schedule transfers within USB 1ms frames.
• Signal USB reset.
• Provide USB power management.
In addition to requiring a dual-role peripheral/host USB controller, OTG
requires additional circuitry to support two new protocols, called HNP (Host
Negotiation Protocol) and SRP (Session Request Protocol).
Host Negotiation Protocol
The OTG specification defines a negotiation protocol, the HNP (Host Nego-
tiation Protocol). This protocol provides a means by which the A- and
B-devices can exchange the OTG host and peripheral roles.
An OTG dual-role device can operate either as a host or peripheral. In
OTG nomenclature, the initial host is called the A-Device, and the initial
peripheral is called the B-Device. The word initial is important. Once con-
nected, OTG dual-role devices can exchange roles – host and peripheral –
by using the new Host Negotiation Protocol (HNP). HNP raises two obvious
questions: (a) how are the initial roles determined; and (b) why is the role
reversal necessary?
The cable orientation determines the initial roles (Figure 8.33). Dual-
role devices use a new receptacle called the mini-AB. The mini-A plug, the
mini-B plug and the mini-AB receptacle add a fifth pin (ID) to give different
electrical identities to the cable ends. This fifth ID pin is connected to ground
inside the mini-A plug and left floating in the mini-B plug. The OTG device
receiving the grounded ID pin is the default A-Device (host); the device with
the floating ID pin is the default B-Device (peripheral).
To understand the need for the HNP and host/peripheral role reversal, the
example in Figure 8.34 shows two dual-role devices, a PDA and a printer.
8.6 USB On-the-Go (OTG): Uses and Support 315
The PDA has a printer driver inside. The two devices are connected with the
new OTG cable as shown, making the printer the default host (A-Device) and
the PDA the default peripheral (B-Device). But this setup is backward. The
PDA, which has the printer driver, needs to act as USB host to the printer,
which contains no driver. Rather than bothering the user to reverse the cable,
HNP allows the devices’ roles to reverse automatically and silently.
to communicate over USB, the A-Device can power down the VBUS wire,
which the B-Device can detect so that it too can enter a low-power state.
Now suppose that the user of the left phone presses a button to synchro-
nize address books, or any other action that requires a USB session. The ‘SRP
Pulse’ block in the left phone pulses first the D+ wire, and then the VBUS wire
to wake up the A-Device. (The A-Device can respond either to D+ or VBUS
pulsing.) The A-Device then detects the pulse, causing it to switch on VBUS
and start a session.
The SRP protocol is more complex than this simple illustration. The B-
Device, for example, must first measure VBUS to ensure that a session is not
in progress. It must also be able to differentiate between a classic PC or an
OTG device at the other end of the cable. It does this by delivering measured
amounts of current to the VBUS wire and noting the resulting voltage.
Once a session is underway, the devices may or may not use HNP.
OTG Transceiver
Next, we are going to examine the requirements for an OTG transceiver,
illustrated in Figure 8.36.
The system given in Figure 8.36 builds on the Figure 8.31 example circuit.
The ASIC block could also be a microprocessor or DSP with USB capability.
Three additions make the transceiver OTG compatible:
1. Switchable pull-up and pull-down resistors on D+/D− to allow periph-
eral or host functionality.
2. Circuitry to monitor and supply 5V power on VBUS as an A-Device, and
to monitor and pulse VBUS as a B-Device initiating SRP.
3. An ID input pin, which is made available as an output to the ASIC.
For this system to operate as a dual-role OTG device, the ASIC, DSP, or
whatever is connected to the transceiver must be capable both of functioning
as a peripheral or host, and of switching roles on-the-fly as a result of HNP.
Most of the added transceiver circuitry manages the VBUS pin, which now
must also supply 5V power at 8mA as a host, and perform VBUS pulsing as
8.6 USB On-the-Go (OTG): Uses and Support 317
a peripheral. Analog switches configure the transceiver for the various roles
that it must play.
custom driver. Table 8.5 shows some of the more common drivers that are
used with Cypress products and some of the capabilities of those drivers.
Devices that do not meet the definition of a specific USB device class
are called vendor-specific devices. These devices allow developers to create
applications with their own creativity and customization options, which are
not bound by a specific USB class, but still conform to the USB specification.
Devices that fall under a vendor-specific device use WinUSB, CYUSB,
LibUSB, or another type of vendor-specific driver. The advantage to using
WinUSB is that it is Windows own vendor-specific driver and does not need to
undergo Windows Hardware Quality Labs (WHQL) testing for driver signing.
WHQL testing is discussed later in this application note. LibUSB is an open
source driver project with support for Windows, Mac, and Linux operating
systems. CyUSB is Cypress’ own vendor-specific driver. The advantage to
using this driver in an application is the broad range of example applications,
supporting documentation, and direct support from Cypress.
In the USB Descriptors section (see USB specifications and also Section
8.10 of this chapter), notice that the fourth byte in the device descriptor and
the sixth byte in the interface descriptor are where the class of the USB device
is defined. The USB specification defines many different USB classes and the
device class codes that go along with them. Table 8.6 shows some USB class
codes that can be used in these bytes to give an idea of the various USB
classes that are available.
8.8 USB Enumeration 321
provides power to the port, and the device is in the Powered state. The device
is in the Attached state and can draw up to 100 mA from the bus.
2. The hub detects the device. The hub monitors the voltages on the signal
lines (D+ and D−) at each of its ports. The hub has a pull-down resistor of
14.25k–24.8kW on each line. A device has a pull-up resistor of 900–1575W
on D+ for a full-speed device or on D− for a low-speed device. High-
speed-capable devices attach at full speed. On attaching to a port, the device
connects to the bus by bringing the appropriate pull-up line high so the hub
324 USB Data Flow
can detect that a device is attached. Except for some devices with weak or
dead batteries, the device must connect within 1 s after detecting that VBUS
is at least 0.8 V. A device can continue to draw 100 mA of bus current
for 1 s after connecting regardless of whether the upstream bus segment is
suspended. On detecting a device, the hub continues to provide power but
doesn’t yet transmit USB traffic to the device.
3. The host learns of the new device. Each hub uses its interrupt endpoint to
report events at the hub. The report indicates only whether the hub or a port
(and if so, which port) has experienced an event. On learning of an event,
the host sends the hub a Get Port Status request to find out more. Get Port
Status and the other hub-class requests used during enumeration are standard
requests that all hubs support. The information returned tells the host when a
device is newly attached.
4. The hub detects whether a device is low or full speed. Just before resetting
the device, the hub determines whether the device is low or full speed by
detecting which signal line has a higher voltage when idle. The hub sends the
information to the host in response to the next Get Port Status request. A USB
1.1 hub may instead detect the device’s speed just after a bus reset. USB 2.0
requires speed detection before the reset so the hub knows whether to check
for a high-speed-capable device during reset as described below.
5. The hub resets the device. When a host learns of a new device, the host
sends the hub a Set Port Feature request that asks the hub to reset the port.
The hub places the device’s USB data lines in the Reset condition for at least
10 ms. Reset is a special condition where both D+ and D− are logic low.
(Normally, the lines have opposite logic states.) The hub sends the reset only
to the new device. Other hubs and devices on the bus don’t see the reset.
6. The host learns if a full-speed device supports high speed. Detecting
whether a device supports high speed uses two special signal states. In the
Chirp J state, only the D+ line is driven, and in the Chirp K state, only the
D− line is driven.
During the reset, a device that supports high speed sends a Chirp K. A
high-speed-capable hub detects the Chirp K and responds with a series of
alternating Chirp K and Chirp J. On detecting the pattern KJKJKJ, the device
removes its full-speed pull-up and performs all further communications at
high speed. If the hub doesn’t respond to the device’s Chirp K, the device
knows it must continue to communicate at full speed. All high-speed devices
must be capable of responding to control-transfer requests at full speed.
8.8 USB Enumeration 325
7. The hub establishes a signal path between the device and the bus. The host
verifies that the device has exited the reset state by sending a Get Port Status
request. A bit in the returned data indicates whether the device is still in the
reset state. If necessary, the host repeats the request until the device has exited
the reset state.
When the hub removes the reset, the device is in the Default state. The
device’s USB registers are in their reset states, and the device is ready to
respond to control transfers at endpoint zero. The device communicates with
the host using the default address of 0x00.
8. The host sends a Get Descriptor request to learn the maximum packet
size of the default pipe. The host sends the request to device address 0x00,
endpoint zero. Because the host itemizes only one device at a time, only
one device will respond to communications addressed to device address 0x00
even if several devices attach at once.
The eighth byte of the device descriptor contains the maximum packet
size supported by endpoint zero. The host may request 64 bytes but after
receiving just one packet (whether or not it has 64 bytes), may begin the
Status stage of the transfer.
On completing the Status stage, Windows may request the hub to reset
the device as in step 5 above. The USB 2.0 specification does not require a
reset here. The reset is a precaution that ensures that the device will be in a
known state when the reset ends. Windows 8 and later skip the second reset
for high-speed devices because these devices typically don’t require a second
reset. If enumeration fails without the second reset, Windows includes the
reset on the next enumeration attempt.
9. The host assigns an address. When the reset is complete, the host controller
assigns a unique address to the device by sending a Set Address request. The
device completes the Status stage of the request using the default address and
then implements the new address. The device is now in the Address state. All
communications from this point on use the new address. The address is valid
until the device is detached, a hub resets the port, or the system reboots. On
the next enumeration, the host may assign a different address to the device.
10. The host learns about the device’s abilities. The host sends a Get Descrip-
tor request to the new address to read the device descriptor. This time the host
retrieves the entire descriptor. The descriptor contains the maximum packet
size for endpoint zero, the number of configurations the device supports, and
other information about the device.
326 USB Data Flow
The host continues to learn about the device by requesting the con-
figuration descriptor(s) specified in the device descriptor. A request for a
configuration descriptor is actually a request for the configuration descriptor
followed by all of its subordinate descriptors up to the number of bytes
requested.
If the host requests 255 bytes, the device responds by sending the
configuration descriptor followed by all of the configuration’s subordinate
descriptors, including interface descriptor(s), with each interface descriptor
followed by any endpoint descriptors for the interface. Some configurations
also have class- or vendor-specific descriptors.
One of the configuration descriptor’s fields is the total length of the
configuration descriptor and its subordinate descriptors. If the value is greater
than 255, the device returns 255 bytes. Windows then requests the configu-
ration descriptor again, this time requesting the number of bytes in the total
length specified in the configuration descriptor.
Earlier Windows editions began by requesting just the configuration
descriptor’s nine bytes to retrieve the total length value, then requesting the
complete descriptor set.
11. The host requests additional information from the device. The host then
may request additional descriptors from the device. In every case, a device
that doesn’t support a requested descriptor should return STALL.
When the device descriptor reports that the device is USB 2.1 or higher,
the host requests a BOS descriptor. If the device returns the BOS descriptor,
the host uses the descriptor’s total length value to request the BOS descriptor
followed by its subordinate descriptor(s).
The host requests string descriptor zero, which contains one or more
codes indicating what languages additional strings use.
If the device descriptor reports that the device contains a serial number
string descriptor, the host requests that descriptor.
If the device descriptor indicates that the device contains a Product string
descriptor, the host requests that descriptor.
For USB 2.0 and higher devices, if Windows doesn’t have a record of
previously retrieving a Microsoft-specific MS OS string descriptor, the OS
may request that descriptor.
If a BOS descriptor or a Microsoft OS string descriptor indicates sup-
port for additional Microsoft-defined descriptors, the host may request these
descriptors.
For USB 2.0 or higher devices operating at full speed with an upstream
USB 1.1 hub, the host requests a device qualifier descriptor. A device that
8.8 USB Enumeration 327
Suspend State. A device enters the Suspend state after detecting no bus
activity, including SOF markers, for at least 3 ms. In the Suspend state, the
device should limit its use of bus power. Both configured and unconfigured
devices must support this state. Chapter 17 has more about the Suspend state.
Device removal
When a user removes a device from the bus, the hub disables the device’s
port. The host knows that the removal occurred after the hub notifies the host
that an event has occurred, and the host sends a Get Port Status request to
learn what the event was. The device disappears from Device Manager and
the device’s address becomes available to another newly attached device.
Traditionally, under Unix, device drivers are linked with the kernel, and
the system is brought down and restarted after installing a new driver. Linux
introduces the concept of a dynamically loadable driver called a module.
Linux modules can be loaded or removed dynamically without requiring the
system to be shut down. A Linux driver can be written so that it is statically
linked or written in a modular form that allows it to be dynamically loaded.
This makes Linux memory usage very efficient because modules can be
written to probe for their own hardware and unload themselves if they cannot
find the hardware they are looking for.
Like Unix device drivers, Linux device drivers are either layered or
monolithic drivers.
hardware the driver is designated to handle. The operating system calls the
driver’s entry point, based on the definition in the code.
of this electronics and the device driver software that is shipped with the
converter to communicate with these electronics over the USB bus. This
section introduces to the reader information needed to help him to get the
proper USB to RS-232 converter.
of the complex USB driver might add extra overhead to the communications,
resulting in delays.
hardware flow control might kick in to prevent data loss. In those situations,
communications may seem error free, but with sometimes bytes lost, or
unspecified errors in the communications.
Sources/References
[1] Executive Comment: The future of mobile connectivity lies in USB On-
The-Go/David Murray and Terry Remple/EBN/November, 13 2001
[2] USB OTG Spec Signals Developers to Proceed with a New Generation
of Mobile Products Capable of Point to Point Data Exchange/USB-IF
Press Release/December 18, 2001
[3] USB On-The-Go: P-to-P Communications in Mobile Devices/Kosta
Koeman and David Murray/Electronic News/August 27, 2001
[4] OTG Supplement to the USB 2.0 Specification, Rev 1.0a/June 24, 2003
9
Wi-Fi Technology
353
354 Wi-Fi Technology
(WLAN) access card and a PDA or laptop. It is a type of local area network
that uses high-frequency radio waves rather than wires to communicate
between nodes. These networks provide a very fast data speed compared with
the data rates of mobile telecommunications technology, and their range is
very limited. Wi-Fi is the most widespread and popular example of WLAN
technology.
Wireless Metropolitan Area Network (WMAN): This network enables
you to access the Internet and multimedia streaming services via a wireless
region area network (WRAN). These networks provide a very fast data speed
compared with the data rates of mobile telecommunication technology as well
as other wireless network, and their range is also extensive.
The high frequency band used by WirelessHD and WiGig lets the two
systems having some technical advantages compared to other network proto-
cols like Wi-Fi but also some limitations. It increases the amount of network
bandwidth and effective data rate they can support. In return for increased
speed, 60 Gbps protocols sacrifice network range. A typical 60 Gbps wireless
protocol connection can only function at distances of 30 ft (about 10 m) or
less. Extremely high-frequency radio signals are not able to pass through most
physical obstructions and so indoor connections are also generally limited to a
single room. On the other hand, the greatly reduced range of these radios also
means that they are much less likely to interfere with other nearby 60 GHz
networks, and makes remote eavesdropping and network security break-ins
much more difficult for outsiders.
Wireless Home Automation Protocols – Z-Wave and ZigBee: Various
network protocols have been created to support home automation systems that
allow remote control of lights, home appliances, and consumer gadgets. Two
prominent wireless protocols for home automation are Z-Wave and ZigBee.
To achieve the extremely low energy consumption required in home automa-
tion environments, these protocols and their associated hardware support only
low data rates – 0.25 Mbps for ZigBee and only about 0.01 Mbps for Z-
Wave. While such data rates are obviously unsuitable for general-purpose
networking, these technologies work well as interfaces to consumer gadgets
which have simple and limited communication requirements.
In the past, home automation was confronted with distance barriers in
large homes and commercial buildings because the network was limited
in how far the signals could travel. Differences in electrical wiring, called
phases, required you to use phase couplers to bridge the signals from
one electrical circuit to another. Large homes with longer wiring distances
experienced weak signals and sporadic performance.
Bluetooth and ZigBee are handled in detail in five chapters of our book
“Smart Home and Microcontroller Networks”. Wi-Fi is the subject of this
chapter.
explanation of the term. The term Wi-Fi was coined as a brand name by the
Wi-Fi Alliance when they were formed and took on board the promotion of
the standard.
The technical name of Wi-Fi is IEEE 802.11. It is one of the family
of IEEE 802.11 standards and is primarily a local area networking (LAN)
technology designed to provide in-building broadband coverage. As a matter
of fact, local area networks of all forms use Wi-Fi as one of the main forms of
communication along with Ethernet. 802.11 is a family of different variant,
for example, 802.11c and 802.11n. All the different variants are different
standards within the overall IEEE 802.11 family. By releasing updated vari-
ants, the overall technology has been able to keep pace with the ever growing
requirements for more data and higher speeds, etc. Technologies including
gigabit Wi-Fi are now widely used.
Wi-Fi is a wireless based technology that allows devices like laptops,
smart phones, TVs, and gaming devices, to connect at high speed to the
internet without the need for a physical wired connection. In addition to this,
computers, laptops, tablets, cameras, and very many other devices use Wi-Fi.
Wi-Fi access is available in many places via Wi-Fi access points or small
DSL/Ethernet routers. Homes, offices, shopping centers, airports, coffee
shops, and many more places offer Wi-Fi access.
Wi-Fi is now one of the major forms of communication for many devices
and with home automation increasing, even more devices are using it. Home
Wi-Fi is a big area of usage of the technology with most homes that use
broadband connections to the Internet using Wi-Fi access as a key means of
communication. For the home, office, and many other areas, Wi-Fi is a major
carrier of data.
Wi-Fi has become the de facto standard for last mile broadband connec-
tivity in homes, offices, and public hotspot locations. Systems can typically
provide a coverage range of only about 1,000 ft from the access point.
Current Wi-Fi systems support a peak physical-layer data rate of 54 Mbps
and typically provide indoor coverage over a distance of 100 ft.
The technology uses license free allocations so that it is free for all to use
without the need for a wireless transmitting license. Typically Wi-Fi uses the
2.4 and 5 GHz Industrial, Scientific and Medical (ISM) bands as these do not
require a license, but it also means they are open to other users as well and
this can mean that interference exists.
Power levels are also low. Typically they are around 100 or 200 mW,
although the maximum levels depend upon the country in which the equip-
ment is located. Some allow maximum powers of a watt or more on some
channels.
362 Wi-Fi Technology
Figure 9.5 How a Wi-Fi access point can be connected on an office local area network.
Although Wi-Fi links are established on either of the two main bands, 2.4
GHz and 5 GHz, many Ethernet routers and Wi-Fi access points provide dual
band Wi-Fi connectivity and they will provide 2.4 GHz and 5 GHz Wi-Fi.
This enables the best Wi-Fi links to be made regardless of usage levels and
interference on the bands.
There will typically be a variety of different Wi-Fi channel that can
be used. The Wi-Fi access point or Wi-Fi router will generally select the
optimum channel to be used. If the access point or router provides dual band
Wi-Fi capability, a selection of the band will also be made. These days, this
selection is normally undertaken by the Wi-Fi access point or router, without
user intervention so there is no need to select 2.4 GHz or 5 GHz Wi-Fi as on
older systems.
In order to ensure that the local area network to which the Wi-Fi access
point is connected remains secure, a password is normally required to be able
to log on to the access point. Even home Wi-Fi networks use a password to
ensure that unwanted users do not access the network.
Many types of device can connect to Wi-Fi networks. Today devices like
smartphones, laptops, and the like expect to use Wi-Fi, and therefore, it is
incorporated as part of the product – no need to do anything apart from
connect. A lot of other devices also have Wi-Fi embedded in them: smart
TVs, cameras, and many more. Their set up is also very easy.
364 Wi-Fi Technology
Occasionally some devices may need a little more attention. These days,
most desktop PCs will come ready to use with Ethernet, and often they
have Wi-Fi capability included. Some may not have Wi-Fi incorporated and
therefore that may need additional hardware if they are required to use Wi-Fi
links. An additional card in the PC or an external dongle should suffice for
this.
In general, most devices that need to communicate data electronically will
have a Wi-Fi capability.
• 802.11g: The 802.11b standard came as a result of the demand for faster
Wi-Fi using the 2.4 GHz band. 802.11g utilizes OFDM technology
and enabled 54 Mbps raw data transfer rates. It was also backward
compatible allowing communication with DSSS but at the lower rate
of 802.11b. Backwards compatibility was a requirement in view of the
number of older access points and computers that might only have the
older standard available, a requirement that is always of importance.
• 802.11h: The IEEE 802.11h-2003 specification defines the power con-
trol required for Wi-Fi. It governs Spectrum and Transmit Power
Management Extensions and addresses issues including the possible
interference with satellites and radar that also use the 5 GHz ISM band.
The standard originally provided for Dynamic Frequency Selection
(DFS) and Transmit Power Control (TPC) to the 802.11a PHY, but it
has also been integrated into the full IEEE 802.11-2007 standard.
• 802.11i: Security is a major issue for Wi-FI as many Wi-Fi hotspots
are in public areas and open to the possibility of hackings gaining
unwanted access to the devices of people using the hotspot. The IEEE
802.11i standard is used to facilitate secure end-to-end communication
for wireless local area networks. The IEEE 80211i standard improves
mechanisms for wireless authentication, encryption, key management,
and detailed security.
• 802.11j: IEEE 802.11j-2004 is an amendment to the basic standard that
extends wireless communication and signaling for 4.9 and 5 GHz band
operations in Japan.
• 802.11k: The IEEE 802.11 standard extends Radio Resource Measure-
ment (RRM) mechanisms for wireless local area networks. It provides
some recommendations about optimizing the WLAN performance.
• 802.11n: 802.11n or, more fully, IEEE 802.11n-2009 is a Wi-Fi standard
that operates in the 2.4 and 5 GHz ISM bands with data rates up to 600
Mbps. It uses MIMO technology along with frame aggregation, and it
also provides security improvements over previous wireless bearer stan-
dards. Wi-Fi Alliance have also labeled the technology for the standard
as Wi-Fi 4.
• 802.11s: This IEEE 802.11 standard amendment addresses the topic of
mesh networking. It details how Wi-Fi devices can interconnect to create
a WLAN mesh network, which may be used for relatively fixed non-
mobile topologies and wireless ad hoc networks.
• 802.11u: IEEE 802.11u-2011 is an amendment to the IEEE 802.11-2007
standard. It adds features that are used for interworking with external
368 Wi-Fi Technology
networks. It is used for roaming and it is also used for the Hotspot2.0
initiative.
• 802.11ac: IEEE 802.11ac gave a major leap in terms of performance
when it was introduced. The standard was released in 2013, but even
though many companies had sight of the standard as it was released
it took a short while after its release before products were seen and it
became widely used. The standard defines a Wi-Fi “wireless network
bearer” that operates below 6 GHz and provides data rates of at least 1
Gbps per second for multi-station operation and 500 Mbps on a single
link. The standard has been labeled as Wi-Fi 5 by Wi-Fi Alliance in view
of its features and performance.
• 802.11ad: 802.11ad also known as WiGi or Gigabit Wi-Fi and it is
designed to provide extremely high throughput data and uses millimeter
wave bands where there are large amounts of bandwidth to achieve this.
It is defined as a Multiple Gigabit Wireless System (MGWS) standard,
and it operates at frequencies up to 60 GHz frequency – it is a networking
standard for WiGig networks.
In view of the very high frequencies used, ranges are very limited – often
just a few meters and it is severely attenuated by objects like walls, etc.,
that would allow signals from lower frequencies through.
• 802.11af: There is often a lot of what is termed White Space in the
regions where television transmitters require guard regions so that trans-
mitters using the same frequency do not interfere. In these regions where
there is the white space, low power signals can be used for a variety of
other services as their power level means they will not travel to far and
cause interference to the primary users. One use for this white space is
Wi-Fi, and IEEE 802.11af has been defined to operate in these regions.
In view of its application and method of frequency use, it is often called
White-Fi.
• 802.11ah: Although the 2.4 and 5 GHz bands are most widely used for
Wi-Fi, there are also some ISM allocations below 1 GHz. IEEE 802.11ah
seeks to use the unlicensed spectrum below 1 GHz. One advantage is
that it will be able to provide long range communications and hence give
support for the Internet of Everything. The drawback of these bands is
that they are relatively narrow and this can limit the data speed.
• 802.11ax: 802.11ax is seen as the future successor to 802.11ac. Using
technologies including OFDMA, MU-MIMO and others its aim is to
increase spectral efficiency and hence the overall usability.
9.5 Wi-Fi Standards: IEEE 802.11 Variants 369
In addition to the standards mentioned above, the IEEE and its working
groups are working towards developing new Wi-Fi standards. These will
ensure that the technology moves forwards in line with the requirements of
the industry and IEEE 802.11 Wi-Fi is able to meet the needs of the future.
Although the network bearer standards like IEEE 802.11g, 802.11n, IEEE
802.11ac, etc. are possibly the most widely known, they are all linked by
the common basic technology behind 802.11. As can be seen by the list
above, there are many 802.11 standards that address topic common to all
Wi-Fi systems. Security, quality of service, authentication and the like are all
important and are required to build a strong environment for the development
and use of Wi-Fi technology.
Brief history of the wireless standards is given in Table 9.1, and technical
comparison between the three major standards is given in Table 9.2.
Table 9.2 Technical comparison between the three major Wi-Fi standards
Feature Wi-Fi (802.11b) Wi-Fi (802.11a/g)
Primary application Wireless LAN Wireless LAN
Frequency Band 2.4 GHz ISM 2.4 GHz ISM (g)5 GHz U-NII (a)
Channel bandwidth 25 MHz 20 MHz
Half-/Full-duplex Half Half
Radio technology Direct sequenceSpread spectrum OFDM(64-channels)
Bandwidth <=0.44 bps/Hz ==2.7 bps/Hz
Efficiency
Modulation QPSK BPSK, QPSK, 16-, 64-QAM
FEC None Convolutional Code
Encryption Optional-RC4m (AES in 802.11i) Optional-RC4(AES in 802.11i)
Mobility In development In development
Mesh Vendor proprietary Vendor proprietary
Access protocol CSMA/CA CSMA/CA
370 Wi-Fi Technology
ISM bands: Wi-Fi is using the unlicensed Industrial, Scientific and Medical
(ISM) bands. These bands have been internationally agreed, and unlike most
other bands, they can be used without the need for a transmitting license. This
gives access to everyone to use them freely.
The ISM bands are not only used by Wi-Fi, but everything from
microwave ovens to many other forms of wireless connectivity and many
industrial, scientific and medical uses.
While the ISM bands are available globally, there are some differences
and restrictions that can occur in some countries.
The main bands used for carrying Wi-Fi are those in Table 9.3.
802.11 systems and frequency bands: The different 802.11 variants in
use are mentioned above. Different 802.11 variants use different bands. A
summary of the bands used by the 802.11 systems is given in Table 9.4.
Figure 9.8 2.4 GHz Wi-Fi channels, frequencies, etc., showing overlap and which ones can
be used as sets.
result, the Wi-Fi channels overlap and it can be seen that it is possible to find
a maximum of three non-overlapping ones. Therefore, if there are adjacent
pieces of WLAN equipment, for example, in a Wi-Fi network consisting of
multiple access points that need to work on non-interfering channels, there
is only a possibility of three. There are five combinations of available non-
overlapping channels given in Figure 9.8.
374 Wi-Fi Technology
From the diagram above, it can be seen that Wi-Fi channels 1, 6, 11, or 2,
7, 12, or 3, 8, 13 or 4, 9, 14 (if allowed) or 5, 10 (and possibly 14 if allowed)
can be used together as sets. Often, Wi-Fi routers are set to channel 6 as the
default, and therefore, the set of channels 1, 6, and 11 is possibly the most
widely used.
As some energy spreads out further outside the nominal bandwidth, if
only two channels are used, then the further away from each other the better
the performance.
It is found that when interference exists, the throughput of the system is
reduced. It therefore pays to reduce the levels of interference to improve the
overall performance of the WLAN equipment.
With the use of IEEE 802.11n, there is the possibility of using signal
bandwidths of either 20 MHz or 40 MHz. When 40 MHz bandwidth is used
to gain the higher data throughput, this obviously reduces the number of
channels that can be used.
Figure 9.9 shows the 802.11n 40 MHz signals. These signals are desig-
nated with their equivalent center channel numbers.
2.4 GHz Wi-Fi channel availability: In view of the differences in spectrum
allocations around the globe and different requirements for the regulatory
authorities, not all the WLAN channels are available in every country.
Table 9.6 provides a broad indication of the availability of the different Wi-Fi
channels in different parts of the world.
Figure 9.9 only provides a general view, and there may be variations
between different countries. For example, some countries within the Euro-
pean zone and Spain have restrictions on the Wi-Fi channels that may be
used (France: channels 10–13 and Spain channels 10 and 11) and do not
allow many of the channels that might be thought to be available, although
the position is likely to change.
Figure 9.9 IEEE 802.11n 2.4 GHz Wi-Fi 40 MHz channels, frequencies, and channel
numbers.
9.6 Wi-Fi Channels, Frequencies, Bands, Bandwidths, and Modulation 375
40 5200 Indoors X X
44 5220 Indoors X X
48 5240 Indoors X X
As other Wi-Fi technologies come to the fore, many other frequencies are
being used. Other unlicensed bands that are below 1 GHz as well as white
space for White-Fi using the unused TV spectrum and also now increasingly
higher frequencies into the microwave region where even greater bandwidths
are available, but at the cost of shorter distance. We remind the reader that
higher frequencies mean less coverage range at the same time allow data to
be transmitted faster than lower frequencies. Shorter coverage because higher
frequencies cannot penetrate solid objects, such as walls and floors. So the
primary differences between the frequencies 2.4 GHz, 5 GHz and less than 1
GHz are the range (coverage) and bandwidth (speed) that the bands provide.
The 2.4 GHz band provides coverage at a longer range but transmits data at
slower speeds. The 5 GHz band provides less coverage but transmits data at
faster speeds.
Each Wi-Fi technology has its own frequencies or bands and sometimes
a different use of the channels
With such increase in the use of Wi-Fi, any engineer working or using Wi-
Fi must have enough knowledge in some essential topics and issues related to
Wi-Fi. Some of the topics are theoretical and some practical.
The aim of this chapter is to give the reader the needed knowledge that
covers such topics. Next is given a short brief upon such issues and topics.
• Wi-Fi variants and standards: As mentioned in Section 9.4, there
are several different forms of Wi-Fi. Each variant is optimum for
some applications. The first variant that was widely available were
IEEE802.11a and 802.11b. They have long been superseded with a
variety of variants offering much higher speeds and generally better
levels of connectivity. There are many different Wi-Fi standard which
have been used, each one with different levels of performance. IEEE
802.11a, 802.11b, g, n, 802.11ac, 802.11ad Gigabit Wi-Fi, 11af White-
Fi, ah, ax, etc. It is important for the designer of Wi-Fi system to select
the variant that is the optimum of this application. This topic is covered
in Section 9.4.
• Security problems: Security concerns have held back Wi-Fi adoption
in the corporate world. Hackers and security consultants have demon-
strated how easy it can be to crack the current security technology known
as wired equivalent privacy (WEP) used in most Wi-Fi connections. A
hacker can break into a Wi-Fi network using readily available materials
and software. This shows how important to study the topic of “Wi-Fi
security” and how to take measures to increase the security of the Wi-Fi
network.
• Using hotspots securely: This topic is completing the previous one:
Security of the network. Wi-Fi hotspots are everywhere, and they are
very convenient to use providing cheap access to data services. But
public Wi-Fi hotspots are not particularly secure – some are very open
and can open up the unwary user to having credentials and other secure
details being obtained or computers hacked, etc. When using public Wi-
Fi, great care must be taken and several rules should be followed to
ensure that the malicious users do not take advantage. Wi-Fi security is
always a major issue.
When using a Wi-Fi link that could be monitored by someone close by,
for example, when in a coffee shop, etc., it is important to make sure
that the link is secure along with the website being browsed, that is, only
visit https sites. It is always wise not to expose credit card details or
login passwords, when on a public Wi-Fi link, even if the Wi-Fi link is
secure. It is all too easy for details to be gathered and saved for use later.
382 Wi-Fi Technology
If using a smartphone, it is far, far safer to use the mobile network itself.
If necessary when using a laptop or tablet, link this to the smartphone
as personal hotspot as this will have a password (remember to choose a
safe one) and this is much less likely to be hacked. Wi-Fi security is the
subject of Section 9.9.
• Compatibility and interoperability: One of the major problems with
Wi-Fi is its compatibility and interoperability. For example, 802.11a
products are not compatible with 802.11b products. Due to different
operating frequencies, 802.11a hotspots would not help an 802.11b
client. Due to lack of standardization, harmonization, and certification,
different vendors come out with products that do not work with each
other.
• Positioning a Wi-Fi router: The performance of a Wi-Fi router can
be very dependent upon its location. When placing the router in bad
(wrong) place, it cannot perform well. By locating a router in the best
position, much better performance can be gained. The location of the
Wi-Fi access point or router is key to providing good performance.
Locating it in the right position can enable it to give much better service
over more of the intended area. This will be discussed in Section 9.8.
• Billing Issues – Wi-Fi vendors are also looking for ways to solve
the problem of back-end integration and billing, which have dogged
the roll-out of commercial Wi-Fi hotspots. Some of the ideas under
consideration for Wi-Fi billing such as per day, per hour, and unlimited
monthly connection fees.
• Band selection: Wi-Fi is currently supported in both the 2.4 GHz and 5
GHz ISM bands. 2.4 GHz will provide better coverage as signals in this
band will penetrate walls and floors, etc. better. But against this 5 GHz
offers a wider bandwidth and will be able to achieve a higher throughput
under ideal conditions.
• Use Wi-Fi coverage planning tools:
When planning Wi-Fi coverage for a major area like a shopping mall
or conference center, a more rigorous approach is needed. Software
planning tools are used along with a comprehensive site survey using
the plans for the area.
These tools look at the Wi-Fi propagation characteristics and then
calculate Wi-Fi coverage.
These tools are not normally viable or accessible for domestic instal-
lations and small offices. It is for these instances where the guidelines
above some in useful.
Even when automated software tools are used, some practical input helps
feed in the relevant data correctly and then adds value to the output from
them.
plugged directly into the main router, typically via the Ethernet port and they
transit a stronger signal.
Usually boosters refer to an upgrade at the Wi-Fi router itself making the
Wi-Fi signal stronger. It can be an amplifier for the transmitted signal, or in
some cases it may be a better antenna.
However, it is important to mention here that a booster is not a total
solution of range extension. To have good coverage, it is necessary to be able
to communicate in both directions. The client, that is, the item connected to
the Wi-Fi router needs to be able to send data back, and the booster, if it is
an amplifier will not affect this. So a booster on its own is unlikely to make
much of a difference in many instances. Better antennas, though will make a
difference as these will normally work in both directions.
extender has the advantage that it does not degrade the performance of the
Wi-Fi network.
key. A WEP comes in different key sizes. The common key lengths are
normally 128 or 256 bits.
The security of the WEP system is seriously flawed. Primarily, it does not
address the issue of key management and this is a primary consideration to
any security system. Normally keys are distributed manually or via another
secure route. The Wi-Fi WEP system uses shared keys – that is, the access
point uses the same key for all clients, and therefore, this means that if the
key is accessed, then all users are compromised. It only takes listening to the
returned authentication frames to be able to determine the key.
Obviously, Wi-Fi WEP is better than nothing because not all people
listening to a Wi-Fi access point will be hackers. It is still widely used and
provides some level of security. However, if it is used, then higher layer
encryption (SSL, TLS, etc.) should also be used when possible. WEP was
officially abandoned by the Wi-Fi Alliance in 2004.
WPA (Wi-Fi Protected Access): In order to provide a workable improve-
ment to the flawed WEP system, the WPA access methodology was devised.
The scheme was developed under the auspices of the Wi-Fi Alliance and
utilized a portion of the IEEE 802.11i security standard – in turn the IEEE
802.11i standard had been developed to replace the WEP protocol.
It increased security by using a pair of security keys: a pre-shared key
(PSK), most often referred to as WPA Personal, and the Temporal Key
Integrity Protocol (or TKIP) for encryption. TKIP is part of the IEEE802.11i
standard and operates by performing per-packet key mixing with re-keying.
Although WPA represented a significant upgrade over WEP, it was also
designed so that it could be rolled out across the ageing (and vulnerable)
hardware designed for WEP. That meant that it inherited some of the well-
known security vulnerabilities of the earlier system.
As a matter of fact, WPA, just like WEP, after being put through proof-of-
concept and applied public demonstrations turned out to be pretty vulnerable
to intrusion. The attacks that posed the most threat to the protocol were
however not the direct ones, but those that were made on Wi-Fi Protected
Setup (WPS) – auxiliary system developed to simplify the linking of devices
to modern access points.
WPA (Wi-Fi Protected Access) scheme provides optional support for
AES-CCMP algorithm. This provides a significantly improved level of
security.
WPA2 (Wi-Fi Protected Access II): The WPA2 scheme for Wi-Fi net-
work security has now superseded the basic WPA or WPAv1 scheme.
390 Wi-Fi Technology
attacks, while the second leads to side-channel leaks. Since WPA2 is widely
used by billions of devices worldwide, the universal adoption of WPA3 is
expected to take a while. As such, most networks will support both WPA3
and WPA2 connections via WPA3’s “transitional mode.”
The transitional mode can be leveraged to carry out downgrade attacks by
setting up a rogue access point that only supports the WPA2 protocol, forcing
WPA3 devices to connect with WPA2’s insecure 4-way handshake.
Researchers also found that the two side-channel attacks against the
password encoding method of Dragonfly allow attackers to obtain Wi-Fi
passwords by performing a password partitioning attack.
b. Safer Connections
When WPA2 came along in 2004, the Internet of Things (IoT) had not yet
become anything close to the all-consuming security horror that is its present-
day hallmark. No wonder, then, that WPA2 offered no streamlined way to
safely onboard these devices to an existing Wi-Fi network. And in fact, the
predominant method by which that process happens today – Wi-Fi Protected
Setup – has had known vulnerabilities since 2011. WPA3 provides a fix.
392 Wi-Fi Technology
Wi-Fi Easy Connect, as the Wi-Fi Alliance calls it, makes it easier to get
wireless devices that have no (or limited) screen or input mechanism onto
your network. When enabled, you will simply use your smartphone to scan a
QR code on your router, then scan a QR code on your printer or speaker or
other IoT device, and you are set – they are securely connected. With the QR
code method, you’re using public key-based encryption to onboard devices
that currently largely lack a simple, secure method to do so.
That trend plays out also with Wi-Fi Enhanced Open, which the Wi-Fi
Alliance detailed before. The reader has probably heard that it is necessary to
avoid doing any sensitive browsing or data entry on public Wi-Fi networks.
That is because with WPA2, anyone on the same public network as you can
observe your activity, and target you with intrusions like man-in-the-middle
attacks or traffic sniffing. On WPA3? Not so much.
When a person log onto a coffee shop’s WPA3 Wi-Fi with a WPA3
device, his/her connection will automatically be encrypted without the need
for additional credentials. It does so using an established standard called
Opportunistic Wireless Encryption.
As with the password protections, WPA3’s expanded encryption for pub-
lic networks also keeps Wi-Fi users safe from a vulnerability they may not
realize exists in the first place. In fact, if anything it might make Wi-Fi users
feel too secure.
before, and so, the basic rating from best to worst of the modern Wi-Fi
security methods available on modern (after 2006) routers is like this:
• WPA2 + AES
• WPA + AES
• WPA + TKIP/AES (TKIP is there as a fallback method)
394 Wi-Fi Technology
• WPA + TKIP
• WEP
• Open Network (no security at all)
It might be, for instance, that your hardware does not support WPA2 or
AES. This is a problem that can be overcome by upgrading your hardware.
The only disadvantage of using WPA2 and AES is that the military-grade
encryption it uses can sometimes slow down your connection. This issue,
though, mainly affects older routers that were released before WPA2 and only
support WPA2 via a firmware upgrade. Any modern router will not suffer
from this problem.
Another bigger problem is that all users are forced to use public Wi-
Fi connections from time to time, and in some cases the level of security
offered on them is poor. The best approach is therefore to be aware of the
level of security offered on the networks you connect to, and to avoid sending
passwords (or other important information) across poorly secured networks.
All of this can be summed up in Table 9.12.
The figure shows clearly that open authentication is not secure at all: it
simply allows any client to authenticate to the network, without the right
security check. This is why open authentication should never be used.
EAP-based 4-way handshake (with WPA/WPA2): When a wireless client
authenticates to the AP, both of them go through the 4-step authentication pro-
cess called 4-way handshake (Figure 9.12). During those message exchanges,
the shared password is derived between AP and wireless client, without being
transmitted in any of those EAP messages.
The Pairwise Master Key (PMK) is something a hacker would like to
collect, in order to break the network encryption scheme. PMK is only known
to the Supplicant and Authenticator, but is not shared anywhere in transit.
9.9 Wi-Fi Security 397
However, the session keys are, and a combination of, ANonce, SNonce,
PMK, MAC addresses of Supplicant and Authenticator. We may write that
relation as the mathematical formula:
Sessions_keys = f(ANonce, SNonce, PMK, A_MAC, S_MAC).
In order to derive a PMK from that equation, one would have to break
AES/RC4 (depending whether WPA2 or WPA is used). It is not that easy as
the only practical approach is to perform a brute-force or dictionary attack
(assuming you have a really good dictionary).
It is definitely a recommended authentication approach to use and
definitely safer than using Open Authentication.
Wi-Fi Chalking: Wi-Fi chalking was a very funny concept in the history
of wireless LAN, mainly used in the USA. The main idea was to mark the
places, where open authentication or WLANs with weak authentication were
implemented. By doing that, everyone who finds out this sign somewhere
on the wall or ground, written with a chalk, can log into the Wi-Fi system
without authentication.
firmware are identified all the time, and with access to the firmware level
of your router there is no end to the mischief that an attacker can cause.
Typically, firmware updates are released to patch specific security vulner-
abilities, and will self-install after you download them. This makes them a
simple step in securing your wireless network.
Wi-Fi Hotspot: In contrast to mobile hotspots that use cellular data to enable
data sharing, Wi-Fi hotspots allow people to get internet access via Wi-Fi
technology. Using a router connecting to an ISP, a Wi-Fi hotspot cannot
be mobile. A Wi-Fi hotspot can either be open or closed as per the host’s
preferences.
Open Public Wi-Fi: A Wi-Fi router connected with an ISP that has inten-
tionally or unintentionally turned off its authentication requirements could be
called open public Wi-Fi. Any device within the range of that router can share
its internet access without any limitation. The host of an open public Wi-Fi
402 Wi-Fi Technology
often has no control over bandwidth allocation or cap over its usage. Open
public Wi-Fi hotspots are usually free, though, risky to connect to.
In terms of hotspot security, open public Wi-Fi networks are least secure
in comparison with other substitutes. Lack of authorization at the time
of establishing the connection is what makes these networks least secure.
Anyone can connect to the network and infect its security. Since worms can
infect devices via nodes, security of any device connected to the network is
compromised.
Further, devices opting to connect to an open public Wi-Fi network are
more susceptible to be connected to a fake network. There are multiple ways
through which security of such hotspot networks can be exploited by hackers.
Thus, we do not recommend connecting to such networks.
Closed Public Wi-Fi: Unlike open public Wi-Fi hotspot, closed public
hotspots usually involve some management and control. Closed public
hotspots have authorization access enabled. Hence, only users with creden-
tials or privileges can access the network. The closed public Wi-Fi hotspot
hosts often manage bandwidth allocation, usage, upload and download limit
or users along with access control – allowing only specific external devices
to the Internet. Such access points are usually paid, but, sometimes free.
In comparison with open public Wi-Fi hotspots, closed public Wi-Fi
hotspots are more steadfast in terms of hotspot security. These networks are
closely administered and require authentication at the time of connection.
These hotspots are likely secure from man-in-the-middle attacks. Moreover,
due to authentication, chances for a user to connect to a fake network are
quite slim.
Another trick hackers use to increase the possibility for a device to con-
nect to a fake network rather the original one is by making the fake network
available in the proximity of the device. By default, the device catches the
stronger signal or the one that is physically closer and gets connected to the
fake network.
Further, the hackers can also take the original network out of the equation
with a simple denial of service attack – leaving insecure devices no other
choice but to connect to a fake and malicious network.
Wi-Fi Pineapple: Wi-Fi Pineapple was never meant to be used for exploiting
devices. The core purpose of creating the device was to pen test system
vulnerabilities and find out loopholes in network or hotspot security. It was
mainly used by ethical hackers to execute network penetration tests.
These penetration tests were ethical since the system proprietor was aware
and had given his consent for them. In short, the access was authorized.
The method gained popularity because it minimized the complexities for
performing network penetration tests which required specialized software and
OS. Nevertheless, the usage of this method is not confined to ethical hacking
only.
If you have forgotten to turn off Wi-Fi on your device, the Pineapple will
intercept your device’s signal – connecting it instantly to a honeypot hotspot.
It then initiates man-in-the-middle attack (explained later) by exploiting net-
work SSID that is recognized by your device. Even though Wi-Fi Pineapple is
connected to the network, the internet connection is not disrupted. Albeit the
security of the network is sabotaged, a user has no idea of what is happening.
Man-In-The- Middle Attack: As the name clearly states, man-in-the-middle
attack refers to an unauthorized network interception. It happens when a
hacker has successfully intercepted your network signal and has now access
to the information you share or receive. Think of it as someone who is
overhearing everything you are saying. What you speak, he listens. What
you write, he reads. Such attacks are usually backed by the motives of
unauthorized access to information and identity theft. The hacker now has
access to your messages, emails, and information you send over the internet.
The hacker will also gain access to your credit card information and
bank details if you intend to do online shopping while your connection is
compromised. Further, they can even access the information that you have
saved during previous transactions. Even though the websites you visit are
Hyper Text Transfer Protocol Secure, the hacker can quickly get around the
404 Wi-Fi Technology
encryption by either routing you to the fake version of a real site or use a
couple of tricks up his sleeve to remove that HTTPS encryption altogether.
Cookie “Sidejacking”: Cookie side-jacking is another form of a man-in-the-
middle attack and is also known as session hijacking. During this hacking
attempt, the hacker gets access to a victim’s online account(s). Whenever you
log in to your account, be it a social media account, online banking or any
website requiring sign-in credentials, the system identifies your credentials
and the server grants you requested access.
Something called a session cookie facilitates this process. This cookie is
stored into your device as long as you are logged in. The moment you sign
out, the server nullifies session token, requiring you to re-enter credentials
the next time you sign in. Cookie side-jacking refers to the situation where
a hacker steals your session token and uses it to grant himself unauthorized
access to your accounts.
Worms – Hotspot: A worm is a malicious computer program that infects
vulnerable networks to spread into the connected devices. The core objective
of this malicious program is to replicate; thus, the moment it infects a device,
it starts spreading. It usually targets devices with security vulnerabilities or
loopholes and can spread through nodes.
Hence, it is safe to assume that worms can infect a device is connected
to a compromised hotspot. Worms not only lower your device’s performance
but, also make them susceptible to hacking attempts.
Wi-Fi – Summary: Wi-Fi is a universal wireless networking technology that
utilizes radio frequencies to transfer data. Wi-Fi allows high-speed Internet
connections without the use of cables.
The term Wi-Fi is a contraction of “wireless fidelity” and commonly used
to refer to wireless networking technology. The Wi-Fi Alliance claims rights
in its uses as a certification mark for equipment certified to 802.11x standards.
Wi-Fi is a freedom – freedom from wires. It allows you to connect to
the Internet from just about anywhere – a coffee shop, a hotel room, or a
conference room at work. What’s more – it is almost 10 times faster than
a regular dial-up connection. Wi-Fi networks operate in the unlicensed 2.4
radio bands, with an 11 Mbps (802.11b) or 54 Mbps (802.11a) data rate,
respectively.
To access Wi-Fi, you need Wi-Fi enabled devices (laptops or PDAs).
These devices can send and receive data wirelessly in any location equipped
with Wi-Fi access.
References 405
References
Useful Links on Wi-Fi
• Wi-Fi Aliance - Official website of Wi-Fi Alliance, the best resource for
Wi-Fi information.
• https://www.netspotapp.com/wifi-encryption-and-security.html
• https://www.electronics-notes.com/
• WiMAX Forum – Official website of WiMAX Forum, the best resource
for WiMAX information.
• IEEE 8092.16 Specification – The IEEE 802.16 Working Group on
Broadband Wireless Access Standards.
• WiMAX Forum White Papers – Read more about WiMAX wireless
technology and how it addresses market problems through these white
papers.
• WiMAX Industry – Find latest news and market trends about WiMAX.
• WiMAX.com – Latest WiMAX news, market trends, WiMAX
Forums, etc.
10
WiMAX
Summary
WiMAX is:
• Acronym for Worldwide Interoperability for Microwave Access.
• Based on Wireless MAN technology.
• A wireless technology optimized for the delivery of IP centric services
over a wide area.
• A scalable wireless platform for constructing alternative and comple-
mentary broadband networks.
• A certification that denotes interoperability of equipment built to the
IEEE 802.16 or compatible standard. The IEEE 802.16 Working Group
develops standards that address two types of usage models –
– A fixed usage model (IEEE 802.16-2004).
– A portable usage model (IEEE 802.16e).
10.1 Introduction
In Section 9.1 of Chapter 9, an introduction to wireless technologies was
given. One of the widely used wireless technologies, the Wi-Fi, was the
subject of Chapter 9. The current chapter, Chapter 10, introduces another
wireless technology, WiMAX.
WiMAX is one of the hottest broadband wireless technologies around
today. WiMAX technology is a wireless broadband communications technol-
ogy based around the IEE 802.16 standard providing high-speed data over a
wide area.
The letters of WiMAX stand for Worldwide Interoperability for
Microwave Access (AXess), and it is a technology for point-to-multipoint
wireless networking.
407
408 WiMAX
f. Link-layer Retransmissions
WiMAX supports automatic retransmission requests (ARQ) at the link layer
for connections that require enhanced reliability. ARQ-enabled connec-
tions require each transmitted packet to be acknowledged by the receiver;
unacknowledged packets are assumed to be lost and are retransmitted.
j. Quality-of-service Support
The WiMAX MAC layer has a connection-oriented architecture that is
designed to support a variety of applications, including voice and multimedia
services.
WiMAX system offers support for constant bit rate, variable bit rate, real-
time, and non-real-time traffic flows, in addition to best-effort data traffic.
WiMAX MAC is designed to support a large number of users, with
multiple connections per terminal, each with its own QoS requirement.
k. Robust Security
WiMAX supports strong encryption, using Advanced Encryption Standard
(AES), and has a robust privacy and key-management protocol.
The system also offers a very flexible authentication architecture based
on Extensible Authentication Protocol (EAP), which allows for a variety of
user credentials, including username/password, digital certificates, and smart
cards.
m. IP-based Architecture
The WiMAX Forum has defined a reference network architecture that is
based on an all-IP platform. All end-to-end services are delivered over an
IP architecture relying on IP-based protocols for end-to-end transport, QoS,
session management, security, and mobility.
10.8.3 Backhaul
A WiMAX tower station can connect directly to the Internet using a high-
bandwidth, wired connection (e.g., a T3 line). It can also connect to another
WiMAX tower using a line-of-sight microwave link.
Backhaul refers both to the connection from the access point back to the
base station and to the connection from the base station to the core network.
It is possible to connect several base stations to one another using high-
speed backhaul microwave links. This would also allow for roaming by a
WiMAX subscriber from one base station coverage area to another, similar to
the roaming enabled by cell phones.
Additional functions that may be part of the ASN gateway include intra-
ASN location management and paging, radio resource management, and
admission control, caching of subscriber profiles, and encryption keys,
AAA client functionality, establishment, and management of mobility
tunnel with base stations, QoS and policy enforcement, foreign agent
functionality for mobile IP, and routing to the selected CSN.
• Connectivity service network (CSN): The CSN provides connectivity
to the Internet, ASP, other public networks, and corporate networks.
The CSN is owned by the NSP and includes AAA servers that support
authentication for the devices, users, and specific services. The CSN
also provides per user policy management of QoS and security. The
CSN is also responsible for IP address management, support for roam-
ing between different NSPs, location management between ASNs, and
mobility and roaming between ASNs.
The WiMAX architecture framework allows for the flexible decomposi-
tion and/or combination of functional entities when building the physical enti-
ties. For example, the ASN may be decomposed into base station transceivers
(BST), base station controllers (BSC), and an ASNGW analogous to the GSM
model of BTS, BSC, and Serving GPRS Support Node (SGSN).
This brings many benefits to those using these data links within buildings and
means that external antennas are not required.
Different bands are available for WiMAX applications in different parts of
the world. The frequencies commonly used are 3.5 and 5.8 GHz for 802.16d
and 2.3, 2.5, and 3.5 GHz for 802.16e but the use depends upon the countries
as shown in Table 10.4.
With WiMAX, users could really cut free from today’s Internet access
arrangements and be able to go online at broadband speeds, almost wherever
they like from within a MetroZone.
WiMAX could potentially be deployed in a variety of spectrum bands:
2.3, 2.5, 3.5, and 5.8 GHz
the transmit/receive transition gap (TTG). After this gap, the users or remote
stations are able to transmit their subframes. The timing of these “uplink”
subframes needs to be accurately controlled and synchronized so that they
do not overlap whatever distance they are from the base station. Once all
the uplink subframes have been transmitted, another short gap known as the
receive/transmit transition gap (RTG) is left before the base station transmits
again.
There are slight differences between the WiMAX subframes transmitted
on the uplink and downlink. The downlink subframe begins with a preamble,
after which a header is transmitted and this is followed by one or more bursts
of data. The modulation within a subframe may change, but it remains the
same within an individual burst. Nevertheless it is possible for the modulation
type to change from one burst to the next. The first bursts to be transmitted
use the more resilient forms of modulation such as BPSK and QPSK. Later
bursts may use the less resilient forms of modulation such as 16 QAM and 64
QAM that enable more data to be carried.
Using this RF interface, WiMAX is able to provide a very effective form
of wireless broadband system that can be sued in many areas.
Note: The IEEE 802.16 standards for BWA provide the possibility for inter-
operability between equipment from different vendors, which is in contrast to
the previous BWA industry, where proprietary products with high prices are
dominant in the market.
426 WiMAX
into multiple small ones in order to further enhance system performance. This
level of flexibility gives significant improvements in overall efficiency.
We are going to discuss again the layers of the stack while discussing
Protocol Architecture and Security Solutions.
• Common Part Sub-layer (CPS), which is the core of the standard and is
tightly integrated with the security sub-layer. This layer defines the rules
and mechanisms for system access, bandwidth allocation and connection
management.
• Security (Privacy) Sub-layer, which lies between the MAC CPS and
the PHY layer, addressing security issues as authentication, key estab-
lishment and exchange, encryption and decryption of data exchanged
between MAC and PHY layers.
The PHY layer provides a two-way mapping between MAC protocol data
units and the PHY layer frames received and transmitted through coding and
modulation of radio frequency signals.
order even WSNs that utilize strong high-layer security mechanisms, simply
because it is often ignored in the initial WSN design. For this reason, we are
giving next some of the countermeasures of jamming attack.
Jamming attack can be prevented by many means, and some of them are
as follows:
• Increasing the power of signals
• Increasing the bandwidth of signals using spreading techniques such as
frequency spread spectrum (FHSS)
• Using direct sequence spread spectrum (DSS)
• Using Radio Direction Finding tools, the sources of jamming are easy to
be located. It is easy to detect jamming using radio spectrum monitoring
equipment.
In the following, some details of these techniques are given taking into
consideration the case of WSN case:
A. Regulated Transmitted Power: The use of low transmission power
decreases the discovery probability from an attacker (an attacker must locate
first the target before transmitting jamming signal). Higher transmitted power
implies higher resistance against jamming because a stronger jamming signal
is needed to overcome the original signal. In some wireless networks espe-
cially Wireless Sensor Network, the nodes possess the capability to change
the output power of their transmitter.
B. Frequency-Hopping Spread Spectrum (FHSS): Frequency-Hopping
Spread Spectrum (FHSS) is a spread-spectrum method of transmitting radio
signals by rapidly switching a carrier among many frequency channels, using
a shared algorithm known both to the transmitter and the receiver. In case of
WSN, FHSS brings forward many advantages in WSN environments:
– It minimizes unauthorized interception and jamming of radio transmis-
sion between the nodes.
– The SNR required for the carrier, relative to the back-ground, decreases
as a wider range of frequencies is used for transmission.
– It deals effectively with the multipath effect.
– Multiple WSNs can coexist in the same area without causing interfer-
ence problems.
One of the main drawbacks of frequency-hopping is that the overall
bandwidth required is much wider than that required to transmit the same
data using a single carrier frequency.
10.14 WiMAX: Protocol Architecture And Security Solutions 437
areas, much like today’s cell phones. We can compare it with Wi-Fi based on
the following factors:
a. IEEE Standards: Wi-Fi is based on IEEE 802.11 standard whereas
WiMAX is based on IEEE 802.16. However, both are IEEE standards.
Wi-Fi is based on IEEE 802.11 standard whereas WiMAX is based on
IEEE 802.16. However, both are IEEE standards.
b. Range: Wi-Fi typically provides local network access for a few hundred
feet with the speed of up to 54 Mbps, and a single WiMAX antenna is
expected to have a range of up to 40 miles with the speed of 70 Mbps
or more. As such, WiMAX can bring the underlying Internet connection
needed to service local Wi-Fi networks.
c. Scalability: Wi-Fi is intended for LAN applications, users scale from
one to tens with one subscriber for each CPE device. Fixed channel
sizes (20MHz). WiMAX is designed to efficiently support from one
to hundreds of Consumer premises equipment (CPE), with unlimited
subscribers behind each CPE. Flexible channel sizes from 1.5 MHz to
20 MHz.
d. Bit rate: Wi-Fi works at 2.7 bps/Hz and can peak up to 54 Mbps in 20
MHz channel. WiMAX works at 5 bps/Hz and can peak up to 100 Mbps
in a 20 MHz channel.
e. Quality of Service: Wi-Fi does not guarantee any QoS but WiMAX
provides several level of QoS.
As such, WiMAX can bring the underlying Internet connection needed to
service local Wi-Fi networks. Wi-Fi does not provide ubiquitous broadband
while WiMAX does.
Table 10.6 gives a summary of the comparison.
References
[1] http://en.wikipedia.org/wiki/802.16
[2] http://en.wikipedia.org/wiki/WiMAX
[3] http://www.wimaxforum.org/about
[4] http://en.wikipedia.org/wiki/Advanced_Encryption_Standard
[5] http://www.cse.wustl.edu/~jain/cse574-08/
[6] David Johnson and Jesse Walker, “Overview of IEEE 802.16 Security”,
Intel Corp, IEEE Security and Privacy, 2004, http://portal.acm.org/citat
ion.cfm?id=1009288
[7] Michel Barbeau, “WiMAX/802.16 Threat Analysis”, Proceedings of the
1st ACM international workshop on Quality of service & security in
wireless and mobile networks, Quebec, Canada 2005. http://portal.acm
.org/citation.cfm?id=1089761.1089764
[8] Mahmoud Narsreldin, Heba Aslan, Magdy El-Hennawy, Adel El-
Hennawy, “WiMAX security”, 22nd International Conference on
Advanced Information Networking and Applications, 2008. http://po
rtal.acm.org/citation.cfm?id=1395554
[9] Andreas Deininger, Shinsaku Kiyomoto, Jun Kurihara, Toshiaki Tanaka,
“Security Vulnerabilities and Solutions in Mobile WiMAX”, Inter-
national Journal of Computer Science and Network Security, VOL.7
No.11, November 2007. http://paper.ijcsns.org/07_book/200711/2
0071102.pdf
[10] Abdelrahman Elleithy, Alaa Abuzaghleh, Abdelshakour Abuzneid, “A
new mechanism to solve IEEE 802.16 authentication vulnerabilities”,
Computer Science and Engineering Department University of Bridge-
port, Bridgeport, CT. http://www.asee.org/activities/organizations/zone
s/proceedings/zone1/2008/Professional/ASEE12008_0022_paper.pdf
[11] Tao Han, Ning Zhang, Kaiming Liu, Bihua Tang, Yuan’an Liu, “Analysis
of Mobile WiMAX Security: Vulnerabilities and Solutions”, Mobile Ad
Hoc and Sensor Systems, 2008. MASS 2008, http://ieeexplore.ieee.org/
document/4660134/
[12] Sen Xu, Chin-Tser Huang, “Attacks on PKM Protocols of IEEE 802.16
and Its Later Versions”, 3rd International Symposium on Wireless Com-
munication Systems, ISWCS 2006. http://ieeexplore.ieee.org/document
/4362284/
[13] Taeshik Shon, Wook Choi, “An Analysis of Mobile WiMAX Secu-
rity: Vulnerabilities and Solutions”, Lecture notes in computer science,
Springer, 2007. http://www.springerlink.com/content/d03p14w7720x8
42l/
450 WiMAX
451
452 INSTEON Technology
cameras, etc., but all are not interconnected and do not use traditional
technology. INSTEON concept is that it connects all devices to form a mesh
network. And the most important concept that attracts all engineers is its
dual band technology. This technology includes transmission of data through
powerline and RF communication. All the devices form peer-to-peer network
such that any device in the network can transmit, repeat, or receive.
Some devices follow only RF communication or communicate via pow-
erline and some devices use both to communicate and are called dual-band
devices. Although it uses both RF and powerline, the networking concept
is very simple and not complicated that includes routing table, addressing,
easily comprehensible data packet, simple error check mechanism and other
cumbersome tasks. All of these together make working of the network
without any impediment.
It employs a dual-mesh networking topology in which all devices are
peers meaning that any device can transmit, receive, or repeat messages inde-
pendently without requiring a master controller or complex routing software.
Like other home automation systems, it has been associated with the Internet
of Things (IoT).
One of the main features of INSTEON is its robustness. An INSTEON
network becomes more robust and reliable as it is expanded because
INSTEON devices repeat messages received from other INSTEON devices.
INSTEON devices repeat each other’s messages by simulcasting them at pre-
cisely the same time, so with more devices the INSTEON signal gets stronger.
Dual-mesh communications using both the powerline and the airwaves ensure
that there are multiple pathways for messages to travel. INSTEON signals
automatically jump from one layer to the other, and back. Each layer works
around road-blocks in the other. It is estimated that the error rate for a
dual-band technology might be 100 times smaller than that of a single-band
technology.
INSTEON-based products were launched in 2005 by Smartlabs, the com-
pany which holds the trademark for INSTEON. A Smartlabs subsidiary, also
named INSTEON, was created to market the technology. There are now mil-
lions of INSTEON nodes in use around the world in many different products,
including dimmers and switches, handheld and tabletop remotes, thermostats,
sprinkler controllers, energy monitoring devices, sensors and low-voltage
input/output interfaces. INSTEON networks easily connect to other, larger
networks, such as LANs and Wi-Fi. Many different user interfaces, including
smartphones, PCs, and third-party controllers, can manage an INSTEON
network. Applications running on such devices not only can talk to INSTEON
11.1 Introduction to INSTEON: Overview 453
products but also can interoperate with cameras, sensors, and other devices
using different networking protocols, including TCP/IP, ZigBee, and Z-Wave.
Devices communicate with each other using the INSTEON protocol over
the air via radio frequency (RF) and over the powerline (PL) as illustrated in
Figure 11.1.
management protocol and now the authority in the same domain. Due to the
network’s rapidness, the name of the protocol INSTEON is derived from the
phrase “Instant on.”
Response Time: Due to dual band feature and due to high speed of the travel-
ling signal, the network does not experience any delay in the transmission of
commands. INSTEON system is build such that a function can be executed in
0.04 s. Hence, the name INSTEON is derived from “Instant On” as explained
earlier.
Affordability: The network is not made to engage into performing cumber-
some algorithms to determine the route to destination and the software used is
simple too. These together make the networking protocol affordable to users.
Backward Compatibility: X10 technology mostly uses existing power-
line to communicate with devices. Also X10 was the recent technology
before INSTEON was evolved. INSTEON technology can work on both RF
and powerline. INSTEON can function with some X10 devices, therefore
INSTEON is called as backward compatible technology.
communicate with each other, which means all the devices are interconnected
with each other. The advantages of this topology are that more than one
communication within the network is possible simultaneously and more than
one routes are available between source and destination. Figure 11.3 shows a
mesh topology, in which all the devices are interconnected.
Figure 11.3 demonstrates a basic INSTEON network, which consists of
nodes that can communicate using a wired medium via powerline and nodes
that can communicate wirelessly via RF communication. One node in the
center of the network in the figure is called as a DB device, which supports
communication wirelessly and on a wired medium.
setup procedure. Adding more devices not only increases the strength of
the simulcast signal but also increases the number of available pathways for
messages to travel. This path diversity results in highly reliable messaging,
so the more devices in an INSTEON network, the better.
Simulcasting does not require routing of the message. This makes the
networking infrastructure much simpler and less expensive than a routed net-
work. Also, the simulcast propagation automatically produces simultaneous
460 INSTEON Technology
response at all responders. This means that responders don’t fire at different
times creating a “popcorn” effect.
1. All devices are capable of receiving a message and resending it. Therefore,
all devices act as repeaters. A node receives a packet, checks for “to address,”
and, if it is destined to it, decodes the information. If the packet is destined to
some other node, then the device sends the packet out without any alteration.
Therefore, all devices follow two-way repeater communication.
2. Sender who sends a packet to the destination node should know whether
it has reached the destination without any impediment or loss; therefore, all
the messages that are received by the destination are acknowledged to the
sender that the receiver got the packet successfully. In INSTEON, all the
messages that are received are acknowledged back to the sender, except for
the broadcast message. This procedure in communication helps successful
transmission of data with high reliability and reduces loss of packets. In the
case of no acknowledgement or ACK is received, the sender retransmits the
packet.
4. Above all discussed concepts, the protocol must have measures to ensure
that the message contents reach the destination without any error. The receiver
may receive erroneous message and respond wrong according to the message
received. This could be fixed using the parity check method, wherein a bit
field included in the message byte informs whether all the bits in the message
hold even or odd parity. More effective mechanisms as Cryptographic hash
function, Repetition codes, Checksum, Cyclic Redundancy Check, or CRC
can be used. X10 Technology has no error detection mechanism, and this is a
drawback for a protocol to be called as a reliable and well-defined protocol.
In INSTEON home networking technology, CRC Protocol is used. Every
message that is sent out from a device has a field in it that stores a value.
This value is called as Cyclic Redundancy Check or CRC value. The sender
before sending the packet and after encoding the information into the packet
subjects, the data bits in the packet to error control algorithm. The result of the
464 INSTEON Technology
process is saved into the CRC field. Now the packet is sent out of the sender,
and the receiver receives the packet and runs the CRC algorithm with input to
the algorithm as the bits in the packet received. The receiver obtains the value
as the result of CRC algorithm and compares the value with the CRC field in
the original packet it received. If the value is same, the packet is categorized
as accurate packet and the receiver starts to decode the information in the
packet. If the values are dissimilar, then the received packet has error and
is dropped, and notifies the sender about the error in the packet by sending
negative acknowledgement.
INSTEON as dual-mesh communication has two protocols: RF Protocol
and Powerline Protocol. The two protocols have same message structure but
have different “Packet” structure.
From Address: This field is a 3 bytes or 24 bits field that holds source
address. This field is used to determine the sender by the receiver node, and in
the case of loss of data, negative data should be sent by the receiver; hence, it
is a necessity for the receiver to know the sender address to send the negative
acknowledgment.
To Address: To identify the message’s destination, to address is encoded into
the packet from the database. If a receiver receives a message, it first checks
the “to address.”
If the “to address” is same as its own receiver device address, then it is
understood that the message is intended to this device that has received the
message; otherwise, the message is retransmitted to the neighbors.
Flags: This field, which is of 1 byte size, describes the type of message and
controls retransmission of the message at the device holding this message.
Table 11.3 shows the flag fields in a standard message.
Message type field in a standard message: The message type field holds the
information on the type of the message. From the fourth bit position, we can
learn that whether the message is standard or extended type of message. If
that field contains the bit value “1,” then the message is an extended message;
otherwise, the message is standard message, if it contains the bit value
“0.” The rest of the bits in the fifth, sixth, and seventh positions play very
466 INSTEON Technology
2. Extended Message
The Extended message, Figure 11.7, is same as the standard message except
the additional user data field which is of size 14 bytes, making the size
of the extended message equal to 24 bytes in total, whereas the standard
message is only 10 bytes. The purpose of having the user field is for advanced
applications.
Table 11.5 presents the data size of each field, which is then followed by
the description of each field.
The user data field is placed in between the command and the CRC field.
Although the user data field is 14 bytes and increases the overall size of the
message, the speed is maintained, INSTEON is still instantaneous. All the
fields except “User Data” are defined before.
User Data: The user data field is the only addition to the standard message
that leads to the formation of extended message. This field is encrypted to
render a secure and private connection between the source and destination.
If the information encoded in the user field exceeds the 14 bytes data field,
more INSTEON extended messages can be appended. The receiver has the
ability to receive and put them together in order using packetizing process.
standard message requires one start packet and four body packets. The total
standard packet is of 120 bits or 15 bytes.
Powerline Extended Message Packet: The extended message packet, Fig-
ure 11.11, comprises of one start packet and 10 body packets. As we know,
the start packet has 12 bits of data message and the body packet has 18 bits of
data message, and therefore, ((1 SP * 12 bits) + (10 BP * 18 bits)) summing
to 192 bits, which is equal to 24 bytes, which is exactly the size of extended
message size. The total size of the extended packet is 264 bits or 33 bytes.
11.5.2.2 RF packet
Unlike powerline packet, RF packets are not broken down into start packet
and body packet. Due to this reason, INSTEON packet sent via RF commu-
nication is faster than the data sent via powerline. The RF standard message
packet, Figure 11.12, and RF extended message packet, Figure 11.13, are
almost same, except the inclusion of data bits, which is 80 bits or 10 bytes in
the case of standard data message and 192 data bits or 24 bytes in the case of
extended data message.
RF Standard Message Packet: This single packet has two sync bytes that
indicate the start of the RF packet, followed by start code byte, which is of
one byte size, indicates the start of data message packet, then follows the 80
bits or 10 bytes of data message bits.
The trailer attached to this packet is the CRC redundant value for error
detection mechanism.
The total packet size comes to 14 bytes.
RF Extended Message Packet: This again has two sync bytes, which spec-
ifies the start of a packet, followed by one start code byte that specifies the
start of message data. The date message of 192 bits or 24 bytes follow and the
packet ends with the trailer, which is of one byte that stores CRC redundant
value.
11.5 The INSTEON Communication Protocols 471
The total size of the packet is 28 bytes, or in the terms of bits, the size of
extended message packet is 224 bits.
80 bits data message, the number of RF standard message packets that can be
sent in one second is 117.5 RF standard message packets. For RF extended
message packet which is of 224 bits or 28 bytes, with 192 bits or 24 bytes of
data message, the number of RF extended message packet that can be sent is
58.7 message packets.
There is also another data rate provided in INSTEON home networking
protocol, which is called as “sustained data rate” and the speed is 2880
bits/s. With this data rate, we can send around 10.9 powerline extended
data message packets in one second. And in the case of standard message
packet type, we can send 24 powerline standard message packets in one
second.
With a sustained speed of 2880 bits/s, 25.7 RF standard message packets
can be sent in one second. And in the case of RF extended message packet,
12.8 packets can be sent in one second.
From the above information, we can infer that using instantaneous data
rate, we can send powerline extended data message packet 4.5 times the
powerline extended data message sent with sustained data rate. And in the
case of powerline standard message, we can send powerline standard message
using instantaneous data rate again 4.5 times the standard message sent with
the help of sustained data rate.
Considering RF standard message packets, with instantaneous speed, we
can send RF standard message packet 4.5 times the RF standard message
packet sent using sustained speed of 2880 bits/s. Similarly with RF extended
message packet, with instantaneous speed, 4.5 times the RF extended
message packet with sustained speed can be sent.
Instantaneous data rate is faster than the sustained data rate, although
sustained data rate is actually fast. Thus, analyzing the data rate we can
come to a conclusion that INSTEON Technology is faster and can operate
and respond to applications much faster in about 0.04 seconds.
However, the INSTEON protocol waits for one additional zero crossing
after each Standard message and for two additional zero crossings after each
Extended message to allow for transmitter “politeness” and possible RF
message transmission. Therefore, the actual sustained bitrate is 2400 bps for
Standard messages or 2437 bps for Extended messages, instead of the 2880
bps it would be without waiting for the extra zero crossings.
INSTEON Standard messages contain 9 bytes (72 bits) of usable data,
not counting packet sync and start code bits, nor the message integrity byte.
Extended messages contain 23 bytes (184 bits) of usable data using the same
criteria. Therefore, the usable data bitrates are further reduced to 1440 bps for
Standard messages and 1698 bps for Extended messages. Counting only the
14 bytes (112 bits) of user data in Extended messages, the user data bitrate is
1034 bps.
These data rates assume that messages are sent with max. hops set to
zero and that there are no message retries. They also do not take into account
the time it takes for a message to be acknowledged. Table 11.6 shows net
data rates when multiple hops and message acknowledgement are taken into
account. To account for retries, divide the given data rates by one plus the
number of retries (up to a maximum of five possible retries).
Device Function: Primarily the INSTEON devices can function as the fol-
lowing types: Controllers, Repeaters, and Responders. These simple device
474 INSTEON Technology
battery operated, whereas the devices that can communicate with the devices
via powerline are powered with regular residential power supply, step down
to required voltage.
Frequency of Operation and Modulation technique: If the device supports
RF communication, to communicate devices wirelessly, the frequency of
operation is 915 MHz. The modulation technique used in the communication
is Frequency Shift Keying (FSK). In wired communication, the wired devices
communicate over powerline using the frequency 131.65 KHz. And the
modulation technique is Bipolar Phase Shift Keying (BPSK).
lighting. This noise is minimal during the time that the current on the
powerline reverses direction, a time known as the powerline zero crossing.
Therefore, INSTEON packets are transmitted during the zero crossing quiet
time, as shown in Figure 11.16.
The top of Figure 11.16 a shows a single powerline cycle, which possesses
two zero crossings. An INSTEON packet is shown at each zero crossing.
INSTEON packets begin 800 microseconds before a zero crossing and last
until 1023 microseconds after the zero crossing.
INSTEON message packets are sent in at the zero crossing of the power-
line only, because at high amplitudes, there could be noise that could disrupt
INSTEON packet. We know that the center frequency is 131.65 KHz, there
are 24 bits in a single INSTEON packet, and each bit takes 10 cycles to reach
the destination. Therefore, 240 cycles are required to send a single INSTEON
packet. With the center frequency 131.65 KHz, the time period is 0.007 ms.
And totally for 24 cycles to carry one INSTEON packet, it takes 1.823 ms or
10823.0 µs (24 cycles * 0.007 ms).
From Figure 11.16, we can notice that the INSTEON packet starts 800 µs
before the powerline signal, and its transmission goes till 1023 µs, therefore
completing one full packet transmission of 1823 µs. The most important
fact that lies in this concept is X10 compatibility. X10 message packet takes
1023 µs to be transmitted to destination. After the powerline signal reaches
zero, both INSTEON packets and X10 packets take 1023 µs to complete the
transmission. Therefore, from this we can understand that both INSTEON
and X10 technologies are compatible and INSTEON technology is actually
backward compatible.
To transfer an INSTEON standard powerline data, we know that one start
packet and four body packets, so totally five packets, are required. While
sending the next data, which requires again five set of standard powerline
message packets, single zero crossing of the powerline is not considered for
transmission of the packet. Therefore, the next zero crossing is used to send
the next set of packets, instead of taking immediate powerline zero crossing.
To transfer five packets of standard powerline data, total time period of
50.01 ms is required as shown in Figure 11.17. Totally, six zero powerline
crossings are used to transmit the powerline standard packet.
Considering extended powerline message packets transmission, totally 11
extended packets of data are sent using 13 zero crossing, two zero crossings
are left without any transmission intermediate of two packet transmission.
The total time period required to transfer the extended powerline packet
would be approximately around 100.02 ms, Figure 11.18,
11.6 INSTEON Communication 479
Source Encoder
Here compression of the digital bits takes place. This avoids sending high
volume of bits by removing redundant bits.
Channel Encoder
Here, error detection mechanism is applied to compute the useful redundant
bits that carry the information of the result obtained from CRC process and
used later at the receiver end.
Modulator
Now the digital processed signal is fed into the modulator to convert it into
analog signal called carrier signal and made suitable for transmission over the
powerline.
Some of the modulation techniques that can be used are BPSK, FSK,
GFSK, etc. In INSTEON, as already mentioned earlier, BPSK is used,
because of its simple method of generation of the signal.
Channel
This is the medium of communication. A channel could be wired or wireless,
but in powerline communication the channel should be definitely a wired one,
where the channel carries both powerline signal and INSTEON data.
The receiver has the blocks shown in Figure 11.20, which is the reverse
of the source end process.
Demodulator: The demodulator is responsible to convert back the analog
carrier signal to its digital equivalent and appropriate for further process.
Channel Decoder: Here error check process takes place. The result is com-
pared with the redundant CRC bits from the received signal, and if both
match the received bits and are error free, they gain entry to the next level
repeated again, and there is no account of how many times the message is
repeated; this situation leads to the flooding of message in the network. This
problem is fixed with the introduction of timeslot synchronization concept to
avoid flooding. Where at the first timeslot the source sends the data, later in
the next, R1 retransmits the data and other devices, although they receive data,
they do nothing and are in just listening state. In this way, the data propagates
and reaches the destination.
Attenuation Characteristics of Carrier in Powerline Communication:
The major attribute of the powerline communication is that the carrier
amplitude faces serious distortion with respect to distance and frequency. To
measure the attenuation characteristics of the carrier, the expression that can
be used is:
Attenuation = 20 log (Vr / Vt)
where Vr is the voltage value of the carrier received, Vt is the voltage value
of the actual carrier voltage transmitted, and as said before in INSTEON
protocol, the carrier voltage is equal to 4.64 V.
Practically as the carrier voltage suffers serious distortion as the message
passes through each node, the researchers term it infeasible to send direct
message to the nodes, so it is a compulsory need to have many nodes between
the sender and the receiver, such that the intermediate nodes as repeaters to
energize the carrier and step up the carrier voltage each time the repeater
receives and send it towards the receiver. In this way, there will be successful
transmission.
References
[1] C. Gomez and J. Paradells, “Wireless home automation networks: A
survey of architectures and technologies,” IEEE Commun. Mag., vol.
48, pp. 92–101, Jun. 2010.
[2] M. A. Zamora-Izquierdo, J. Santa, and A. F. GÃşmez-Skarmeta, “An
integral and networked home automation solution for indoor ambient
intelligence,” IEEE Pervasive Computing, vol. 9, pp. 66–77, Jan. 2010.
[3] Smarthome. (2015). Remote controllers. [Online]. Available: http://ww
w.smarthome.com/controllers-apps/remote-controllers.html
[4] M. H. Mazlan, F. Mohamad, R. A. Rashid, M. A. Sarijari, and M. R. A.
Rahim. “Realtime communication routing protocol for home automation
via power line,” paper presented at 7th Student Conf. on Research and
Development, Johor Bahru, Malaysia, 2008.
[5] Insteon, “Insteon whitepaper: The details,” Insteon, Irvine, CA, version
2.0, 2013.
[6] Yu-Ju Lin, H. A. Latchman, M. Lee, and S. Katar, “A power line com-
munication network infrastructure for the smart home,” IEEE Wireless
Communications, vol. 9, pp. 104–111, Dec. 2002.
[7] L. Lampe and A. J. Han Vinck, “Cooperative multihop power line com-
munications,” presented at IEEE Int. Symp. on Power Line Commun.
and App., Beijing, China, Mar. 2012.
[8] G. Bumiller, L. Lampe, and H. Hrasnica. “Power line communica-
tion networks for large-scale control and automation systems,” IEEE
Commun. Mag., vol. 48, pp. 106–113, Apr. 2010.
486 INSTEON Technology
A Baud
Attack Rate 12, 61, 234, 349
Dictionary attack 390, 391, 397
Denial of Service 403, 444 C
Man-in-the-middle 392, 403, Cables
433, 446 Maximum length 166, 230,
Jamming attack 435, 436, 266, 268
437, 438 RS-232 null modem 135,
Scrambling attack 438 138, 139
Water torture attack 435, 438 Straight through 51, 94,
Masquerading threat 443 133, 279
Authentication Tail circuit 133, 135
Modes 15, 89, 203, 337 Types of serial 48, 50, 121, 133
Open authentication 395, Characteristics
396, 397 Electrical 41, 170, 185, 456
EAP-based 4-way Functional 5, 185, 301, 467
handshake 396 Mechanical 104, 170, 231, 278
Pre-shared Key 389, 395 Communication
Half duplex 18, 161,
B 217, 424
Bit Full duplex 7, 49, 196, 226
Banging 207 Parallel 1, 15, 167, 426
Duration 27, 35, 116, 426 Serial 38, 131, 313, 456
Parity 20, 93, 239, 463 Serial data 1, 102, 170, 246
Rate 12, 183, 412, 447 Serial Data Communication
Sampling 22, 54, 197, 422 Standards 8
Start 17, 124, 289, 470 Serial versus parallel 12
Stop 52, 101, 276, 444 Simplex 49, 160, 192, 231
Synchronous 39, 89, 188, 232 Converters
Synchronous operation 18, 31, DB9 to DB25 126, 127
33, 89 DB25 to DB9 126, 128, 129
Synchronization 15, 30, 56, 484 RS-232 to DB9 40, 126
487
488 Index
D L
Data Line-of-sight 411, 414, 417, 421
Communication 1, 96, Loop
331, 437 Current 44, 182, 273, 429
Pins 18, 135, 209, 278 Phase-locked 31, 34, 36, 37
Serial Data Standard 24, 93,
169, 176 M
Terminal equipment 16, 50, Manchester coding 27, 32, 36, 37
133, 180 Modulation
Timing 11, 98, 390, 476 Non-return to zero 24, 26, 32, 37
Data Rate Return to zero 24, 27, 32, 37
Instantaneous 468, 471, 472 Adaptive modulation and
Sustained 260, 472, 473 coding in WiMAX 422
E N
Error Non-line-of-sight 411, 414, 421
Framing 23, 86, 89, 250
Overrun 87, 144 P
Parity 52, 100, 239, 463 Point-to-point
Underrun 87, 89 Bridge 1 265, 280, 354, 456
Protocol
H Communication 1, 27, 153, 368
Handshaking Inter system 3, 5
Hardware 1, 151, 217, 389 Intra system 3, 6, 8
RS-232 11, 105, 247, 456
RS-232 in minimal R
handshaking Router
application 161 Ethernet 17, 185, 387, 485
Software 1, 142, 339, 455 Location 44, 397, 415, 432
Xmodem 142, 147, 148 RS-232
Hotspot Interface 1, 177, 231, 349
Evil twin 402 In minimal handshaking
Main threats 402 application 161
Mobile 255, 401, 430, 454 Null modem 50, 151, 156, 166
Personal 125, 365, 401, 484 RS-422
Portable 246, 359, 407, 438 Applications 1, 164, 214, 480
Wi-Fi 353, 371, 386, 461 Characteristics 1, 111, 187, 484
Worms 402, 404 Network topology 174, 184, 456
Index 489
RS-449 W
Auxiliary connector 178 Wi-Fi
Connector pinout 171, 178, 252 Access point 354, 364, 391, 417
Interface 1, 188, 247, 456 Access protocols 379
RS-485 Standards 1, 162, 366, 448
Application 24, 333, 351, 480 Channels 2, 372, 422, 440
Differential signal 99, 180, Frequencies 57, 375, 378, 436
233, 243 Modulation 25, 370, 425, 476
Functionality 5, 329, 420, 467 Multimedia extensions
Network topology 174, 184, 456 (WME) 379
Specification overview 181 Variants and standards 381
RS-530 Pineapple 403
Interface application 187 Boosters, range extenders,
Interface characteristics 124, 176, and repeaters 386
187, 206 Security 24, 389, 433, 451
Pin configuration 118, 188 Vulnerability 390, 394, 440, 445
KRACK 391, 394
S Authentication modes 395
Security EAP-based 4-way handshake 396
Risk 4 156, 273, 401, 433 Chalking 397
Standard Hotspot 355, 400, 403, 423
Electrical interface 41, 42 Open public 400, 401, 402
Recommendation 98, 366, Closed public 402
367, 397 WiMAX
Station Adaptive modulation and
Base 6, 349, 407, 446 coding 415, 422
Subscriber 356, 420, Backhaul 375, 411, 413, 417
440, 447 Basics 104, 409, 426
Synchronization Base station 356, 416, 420, 446
Character 1, 33, 89, 174 Benefits 167, 246, 413, 428
Frame 10, 322, 410, 446 Building blocks 416
Need for 1, 251, 371, 453 Features 19, 211, 302, 461
Frequencies and spectrum
V allocations 422
Vulnerability IEEE standards 425, 447
KRACK 391, 394 Network architecture 416, 418,
Modes 15, 203, 223, 395 419, 431
490 Index
Physical layer 24, 89, 421, 431 WiMAX – MAC layer 427
Protocol architecture and security WiMAX – Mobility support 430
solutions 430, 431 Threats to the PHY layer 435
Receiver 1, 85, 148, 387 Versions 9, 248, 280, 412
Reference network model 417 Vulnerabilities and
Security 24, 367, 446, 491 countermeasures 435
About the Authors
Prof. Dawoud Shenouda Dawoud has a BSc (1965) and MSc (1969) from
Cairo University in Communication Engineering. He completed his PhD in
Russia in 1973 in the field of Computer hardware where he succeeded to
own 3 Patents in the field of designing new types of memory which was the
beginning of the FPGAs. In 1984, he was promoted to full Professor at the
Egyptian Academy of Science and Technology, National Electronic Research
Institute. During the period from 1973 to 1990, he supervised more than 5
PhDs and 15 MSc degrees all of them focused in the fields of computer and
embedded system designs. During the period from 1990-1999 he established
the Faculty of Engineering at the University of Botswana. During this period
he supervised 3 PhDs and 7 MSc degrees. In the year 2000 he became
Professor of Computer Engineering and Head of the Computer Engineering
Department at the University of KwaZulu Natal, Durban, South Africa. For
10 years he was supervising research in the field of Security of Mobile Ad
hoc Networks. He supervised 2 PhDs and many MSc degrees in this field
and published more than 30 papers. At the same period, he was visiting the
National University of Rwanda to run an MSc program in Communication.
He supervised about 15 MSc students during these 4 years before moving to
the National University of Rwanda in 2010 to become the Dean of the Faculty
of Engineering.
In 2011 he moved to Uganda where he became the Dean of the Faculty of
Engineering at the International University of East Africa (IUEA), where he
currently remains. During this time, he also served as the Vice Chancellor of
IUEA, for a period of 3 years.
Across his career, he has published over 200 Journal and Conference
papers, as well as books in the fields of computer engineering, microcon-
troller system design, embedded system design and Security of Mobil Ad
hoc Networks.
491
492 About the Authors
Peter Dawoud has been working in the area of biometrics and computer
vision for the last six years, leading research and products within Microsoft
in the space. After completing his Bachelor’s degree in computer engineering,
Peter spent time researching applied cryptographic and steganographic sys-
tems for his Master’s Degrees. Upon completion of these degrees, Peter has
been focused on the productization of biometric systems for consumer and
enterprise scenarios and later focused on the principles and use of centralized
cloud biometrics systems in the enterprise and commercial scenarios.
River Publishers Series in Communications
Serial Communication