UART - Universal Asyncrohonus Transmitter Reciever

What is UART?

  • UART is a protocol that is used to communicate between microcontrollers

  • It is typically implemented with the following 3 physical logic levels:

    • TTL

    • RS-232

    • RS-422

    • RS-485 (Outside the scope of this document, not hard to pick up)

  • For those who have used Arduino, UART is the protocol that is used to facilitate ‘Serial’ communication

Signals Overview

  • TX

    • Transmit signal as viewed from a microcontroller (i.e. signals will be going out of this pin)

  • RX

    • Receive signal as viewed from a microcontroller (i.e. signals will be coming into this pin)

  • RTS

    • Request to send, either high or low

  • CTS

    • Cleared to send data, either high or low

Note, the TX wires of one microcontroller are wired to the RX wires of the other microcontroller. A similar situation occurs on the RTS and CTS wires. Always verify that the TX and RX wires are swapped.

UART Signal Schematic, Credit: https://www.airsupplylab.com/lab_psoc5lp/76-learn/learn-embedded/communication/100-universal-asynchronous-receiver-transmitter-uart.html

USART vs UART

Some connections called USART (Universal Synchronous/Asynchronous Receiver/Transmitter) add a clock signal to the signals seen above. The clock signal regulates the rate of data transmission and removes the need for both sides to agree on a baud rate.

The sending device or an external source will transmit a clock signal that will allow the devices to read specific bits. The clock signal will be labeled CLK or Clock.

Theory of Operation

Timing diagram for UART, credit: link here.

Application Notes

  • CTS/RTS and other signals do exist (technically not UART, but I don’t want to get into why), but are not required in the majority of applications. Instances where these signals are used include programming and resetting microcontrollers, or communicating if a device has data ready or not. TL;DR, you can get away with just TX & RX

  • You don’t need to have both TX and RX, there is no sort of handshaking etc, so you can have a device that is only capable of transmitting and a device only capable of listening etc.

  • The most popular instance of UART being used in my opinion is a USB-UART bridge as it is a cheap way to implement USB while using UART on the microcontroller end and letting a chip do the fancy work.

  • Don’t use this protocol for anything with super high data transfer conditions, you’ll start to cap out at a nominal frequency of ~15kHz, which is nothing compared to a synchronous protocol where rates of 5MHz can be used without breaking a sweat.

  • In my opinion, UART is one of the easiest protocols to implement.

Common mistakes

  • Ensure that TX and RX are swapped as per above

    • on our blue USB-TTL cables, the green wire is tx, and the white is rx

  • The baud rate typically needs to be within +- 5% of the original baud rate, otherwise it will be mismatched and you will be unable to read anything.

  • Always check the tolerances on the clock of your MCU before using it in an async protocol application. If you don’t you may end up falling for baud rate mismatch. Note that typically an internal oscillator won’t cut it.

More reading