Updated: Sep 9
Universal Asynchronous Reciever-Transmitter
The transmitter converts parallel data from a controlling device like a CPU into serial form, transmits it in serial to the receiving UART, which then converts the serial data back into parallel data for the receiving device. Data flows from the Tx pin of the transmitter to the Rx pin of the receiver hence only two wires are needed to transmit data.
UART transmit data asynchronously, which means there is no clock signal to synchronise the output of bits from the transmitter to the sampling of bits by the receiver. The transmitter adds start and stop bits to the data packet being transferred which define the beginning and end of the data packet so the receiver knows when to start reading the bits. When the receiver detects a start bit, it starts to read the incoming bits at baud rate. Both operate at about the same baud rate and must also must be configured to transmit and receive the same data packet structure.
The UART that is going to transmit data receives the data from a data bus. The data bus is used to send data by another device like a CPU, memory, or controller. Data is transferred from the data bus to the transmitting UART in parallel form after which, it adds a start bit, a parity bit, and a stop bit, creating the data packet. Next, the data packet is output serially, bit by bit at the Tx pin. The receiver reads the data packet bit by bit at its Rx pin. The receiving UART then converts the data back into parallel form and removes the start bit, parity bit, and stop bits. Finally, the receiving UART transfers the data packet in parallel to the data bus on the receiving end. The data transmitted is organized into packets where each packet contains 1 start bit, 5 to 9 data bits, an optional parity bit, and 1 or 2 stop bits.
UART data transmission
1. The transmitting UART receives data in parallel from the data bus:
2. The transmitting UART adds the start bit, parity bit, and the stop bit(s) to the data frame:
3. The entire packet is sent serially from the transmitting UART to the receiving UART. The receiving UART samples the data line at the pre-configured baud rate:
4. The receiving UART discards the start bit, parity bit, and stop bit from the data frame:
5. The receiving UART converts the serial data back into parallel and transfers it to the data bus on the receiving end:
No communication protocol is perfect, but UARTs are pretty good at what they do. Here are some pros and cons to help you decide whether or not they fit the needs of your project:
Only uses two wires
No clock signal is necessary
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
Well documented and widely used method
The size of the data frame is limited to a maximum of 9 bits
Doesn’t support multiple slave or multiple master systems
The baud rates of each UART must be within 10% of each other.
Serial Peripheral Interface (SPI)
Two way communication
Fully duplex mode
Data rates up to 10 Mbps
Single master with multiple slaves
SPI protocol uses four types of signals, namely -
MOSI : Master Out Slave In
MISO : Master In Slave Out
SCLK : Serial Clock
SS : Slave Select (unique for each slave device)
Application areas and modules : RFID cards, SD cards, 2.4 GHz Wireless
Inter Integrated circuit bus
Developed by Philips in 1980s
It is low bandwidth, short range protocol for on-board communication
Master - slave protocol
Master controls clock (SCL)
Supports multiple data speeds
Has built-in collision detection
Every slave device has a unique address.
Data is transferred in a serial fashion along Serial Data (SDA) line.