UART: Basics

UART is a type of communication device. “UART” stands for Universal Asynchronous Receiver Transmitter, and it is asynchronous, full-duplex, and serial. In other words, UART does not use any shared clock signals, both devices in the system can transmit and receive data at the same time, and data is sent one bit at a time. Contrary to what the acronym implies, UART is not the only communication system that exists, and it is not always the most efficient one to use for every situation. However, UART is a simple system to implement; thus, it sees a lot of use in small scale communication between two devices.

(Source: http://www.circuitbasics.com/basics-uart-communication/

A UART packet consists of one start bit (always 0/logic low), several data bits, possibly a parity bit, and one or two stop bits (always 1/logic high). This packet is known as a data frame, and the size of a data frame is the number of bits in the frame.

When a UART is not receiving any data, it is in an idle state, where the data line is active-high until a packet is received. The receiver can tell when a packet is arriving due to the start bit, which is always logic low. After the start bit comes, the next set of bits are the data bits, followed by a possible parity bit, then the stop bit(s).

Notice that these are vague descriptions of the procedure. Since these parameters are flexible and could range from any set of numbers, it is essential to specify beforehand how the data packets are structured. The packets can be described with the following format: [DPS], where D is the number of data bits, P is the parity (E for even, O for odd, N for none), and S is the number of stop bits. For example, a packet with a format of [5E2] has five data bits, even parity, and two stop bits. So the data frame for that includes 9 bits. The below the picture shows an example of such data frame.

This communication scheme necessitates that both devices in the UART are configured to handle the same kind of packets. If one method is transmitting a [8E1] packet, but the other device is expecting to receive a [9N2] packet, there is bound to be data corruption since the packages do not match up.

The below image shows two characters passed between the laptop and the board using UART using [8N1] format.