Serial Port Complete - Latest Microcontroller projects

(lily) #1

Chapter 2


computer must match within a few percent. A transmitted Start bit synchro-
nizes the transmitter’s and receiver’s clocks.
In contrast, in a synchronous protocol, the interface includes a clock line typi-
cally controlled by one of the computers, and all transmitted bits synchronize to
that clock. Each transmitted bit is valid at a defined time after a clock’s rising or
falling edge, depending on the protocol. Examples of synchronous serial inter-
faces are I^2 C, SPI, and Microwire.


  • 

    


A UART transmits data in chunks often called words. Each word contains a
Start bit, data bits, an optional parity bit, and one or more Stop bits.
Most UARTs support multiple word formats. A common format is 8-N-1,
where the transmitter sends each word as one Start bit, followed by eight data
bits and one Stop bit. The data bits transmit beginning with bit 0 (the least sig-
nificant bit, or LSb). Figure 2-1 illustrates.
The N in 8-N-1 indicates that the words don’t contain a parity bit. Formats
that use the parity bit can use a parity type of even, odd, mark, or space. An
example format using parity is 7-E-1 where the transmitter sends one Start bit,
seven data bits, an even parity bit, and one Stop bit.
The parity bit can provide a basic form of error detecting. With even parity, the
data bits and parity bit in each word contain an even number of 1s. With odd
parity, the data bits and parity bit in each word contain an odd number of 1s.
For example, assume the data bits to send are 0000001b. With even parity, the
parity bit is 1 to bring the total number of 1s in the data and parity bits to an
even number. With odd parity, the parity bit is 0 to keep the total number of 1s
odd. If the data bits are 0000011b, with even parity, the parity bit is 0, and with
odd parity, the parity bit is 1. If the communications are using 7-E-1 format, a
receiving computer that receives a byte with an odd number of 1s knows the
data didn’t transmit correctly.
Mark and space parity are forms of stick parity. With mark parity, the parity bit
is always 1, and with space parity, the parity bit is always zero. One use for these
parities is in 9-bit networks that use mark and space bits to indicate whether the
data bits contain an address or data. Chapter 12 has more about 9-bit networks.
Most UARTs support 7- and 8-bit data. Some UARTs support anywhere from
5 to 8 data bits. The data bits in a transmitted word are sometimes referred to as
a character and may in fact represent a text character.
Free download pdf