Wednesday, July 8, 2020

UART communication protocol (embedded system)

What is UART?
• Universal asynchronous receiver / transmitter
• Protocol for exchanging serial data between
two devices
TX
TX
• Uses only two wires
- TX to RX (each direction)
• Can be simplex, half-duplex, or full-duplex
• Data is transmitted as frames.

Where is UART used?
• UART was one of the earliest serial protocols
Serial (COM) ports, RS-232, modems, etc.
• Popularity of UART is however decreasing:
- SPI and 12C between components
- Ethernet and USB between computers and
peripherals
• Still important for lower-speed, low-throughput
applications

About timing / synchronization
• UART is asynchronous – the transmitter and
receiver do not share a common clock
Common UART
baud rates
• The transmitter and receiver therefore must:
Transmit at the same (known) speed
- Use the same frame structure / parameters.
UART frame format:
  • UART frames consist of:
  • Start / stop bits
  • - Data bits
  • Parity bit (optional)
  • • High voltage ("mark") = 1, low voltage ("space") = 0

Start and stop bits
• The start bit indicates data is coming
Transition from idle (high) to low
The stop bit(s) indicate data is complete
Stay / return to idle (high)
- Second (optional) stop bit.


Data bit :
• User (useful) data
• Length: 5 to 9 bits (usually 7 or 8)
• Data is typically sent with the least
significant bit (LSB) first.

Example:
- 7-bit ASCII 'S' (0x52) = 1 0 10011

LSB order= 110010 1


Parity bit (optional)
• Used for error detection
• Example:
ASCII 'S' (0x52 = 1010011) four 1's
- If even parity, parity bit is 0 (because
number of 1's already even)
• Even parity: number of 1's must be even
• Odd parity : number of 1's must be odd
- If odd parity, parity bit is 1 (to make the
number of 1's odd)

Summary
• UART = universal asynchronous receiver / transmitter
Simple, two-wire protocol for exchanging serial data
No shared clock – baud rate must be configured the
same on both sides
Start / stop bits used to frame user data
Optional parity bit for detecting single-bit errors
• Widely used serial data protocol, but slowly being
replaced by SPI, 12C, USB and Ethernet.

1 comment:

How to Invest in Stocks A Beginner’s Guide

Investing in stocks can be a great way to grow your wealth over time, but it's important to do your research and approach it with a long...