The Usart Bla bla bla
A little disquisition about USART and AVR microcontroller

Synchronous Serial Transmission
Synchronous serial transmission requires that the sender and receiver share a clock signal so that the receiver knows how to understand the coming bit of the data. In most forms of serial Synchronous communication, if there is no data available at a given time to transmit, a “fill” character must be sent so that data is always being transmitted (Idle flag). Synchronous communication is usually more efficient than the asynchronous one because only data bits are transmitted between sender and receiver but it requires extra wiring to share a clock signal.

Asynchronous Serial Transmission
Asynchronous transmission allows data to be transmitted without sharing the clock signal. The sender and receiver must agree on timing parameters in advance and special bits are added to each byte so to synchronize the sending and receiving units.
The following table describes a byte of data sent using the Asynchronous transmission.

 

Start Bit Bit 0 Bit 1 Bit 2 Bit 5 Bit 6 Bit 7 Parity Bit Stop Bit 1 Stop Bit 2

Table: One byte asynchronous transmission protocol

A bit, called the "Start Bit", is added to the beginning of each word that is to be transmitted. The Start Bit is used to alert the receiver that a word of data is about to be sent. It is also used to force the clock in the receiver to to begin the synchronization with the clock of the transmitter. These two clocks must be accurate enough to not have the frequency drift by more than 5% during the transmission of the remaining bits in the word.

Once the Start Bit, the data bits  are sent. They may either be 5, 6, 7, or 9 data bits, depending on the number selected. Both receiver and the transmitter must agree on the number of data bits. Almost all devices transmit data using either 7 or 8 data bits. Notice that when only 7 data bits are used, the highest ASCII values that could be sent is 127. Likewise, using 5 bits limits the highest possible value to 31. The Least Significant Bit (LSB) of the data bits is sent first of the Most Significant Bit (MSB). Each bit in the transmission side is transmitted for exactly the same amount of time as all of the other bits. The receiver “looks” on the wire at approximately halfway through the period assigned to each bit to determine if the bit is a 1 or a 0.
For example, if it takes two seconds to send each bit, the receiver will examine the signal to determine if it is a 1 or a 0 after one second has elapsed, then it will wait two seconds and then examine the value of the next bit, and so on (the sender knows when the clock says to begin transmitting the next bit of the byte).

When the entire data byte has been sent, the transmitter may add an optional Parity Bit . The Parity Bit may be used by the receiver to perform simple error checking. The parity could be one of even, odd, none, mark and space. When even or odd parity is being used, the number of marks (logical 1 bits) in each data byte are counted, and a single bit is transmitted following the data bits to indicate whether the number of 1 bits just sent is even or odd. Mark parity means that the parity bit is always set to the mark signal condition and likewise space parity always sends the parity bit in the space signal condition. Since these two parity options serve no useful purpose whatsoever, they are almost never used. 

Then at least one Stop Bit is sent by the transmitter (generally is possible to send up to 3 Stop bit).
When the receiver has received all of the bits in the data word, it may check for the Parity Bits and then the receiver looks for a Stop Bit (both sender and receiver must agree on whether a Parity Bit is to be used and how may Stop bit are sent) . If the Parity Bit of the sender is different from the one computed by the receiver, the receiver will report a Parity Error. If the Stop Bit does not appear when it is supposed to be, the UART of the receiver discards the entire byte and it will report a Framing Error. The usual cause of a Framing Error is that the sender and receiver clocks were not running at the same speed. If the sender and receiver are configured identically, the Start Stop and Parity bits are not passed to the host. If another byte of data is ready for transmission, the Start Bit for the new word can be sent as soon as the Stop Bit for the previous word has been sent.

In asynchronous, if there is no data to transmit, the transmission line can be idle, the UART is auto synchronize.

Other UART Functions
In addition to the basic job of converting data from parallel to serial for transmission and from serial to parallel on reception, a UART will usually provide additional circuits for signals that can be used to indicate the state of the transmission media, and to regulate the flow of data in the event that the remote device is not prepared to accept more data. For example, when the device connected to the UART is a modem, the modem may report the presence of a carrier on the phone line while the computer may be able to instruct the modem to reset itself or to not take calls by raising or lowering one more of these extra signals. The function of each of these additional signals is defined in the EIA RS232-C standard.

(to be continued…)

The index page