UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (2024)

Abstract

UART, or universal asynchronous receiver-transmitter, is one of the most used device-to-device communication protocols. This article shows how to use UART as a hardware communication protocol by following the standard procedure.

When properly configured, UART can work with many different types of serial protocols that involve transmitting and receiving serial data. In serial communication, data is transferred bit by bit using a single line or wire. In two-way communication, we use two wires for successful serial data transfer. Depending on the application and system requirements, serial communications needs less circuitry and wires, which reduces the cost of implementation.

In this article, we will discuss the fundamental principles when using UART, with a focus on packet transmission, standard frame protocol, and customized frame protocols that are value added features for security compliance when implemented, especially during code development. During product development, this document also aims to share some basic steps when checking on a data sheet for actual usage.

At the end of the article, the goal is for better understanding and compliance of UART standards to maximize the capabilities and application, particularly when developing new products.

“The single biggest problem in communication is the illusion that it has taken place.”
—George Bernard Shaw

Communication protocol plays a big role in organizing communication between devices. It is designed in different ways based on system requirements, and these protocols have a specific rule agreed upon between devices to achieve successful communication.

Embedded systems, microcontrollers, and computers mostly use UART as a form of device-to-device hardware communication protocol. Among the available communication protocols, UART uses only two wires for its transmitting and receiving ends.

Despite being a widely used method of hardware communication protocol, it is not fully optimized all the time. Proper implementation of frame protocol is commonly disregarded when using the UART module inside the microcontroller.

By definition, UART is a hardware communication protocol that uses asynchronous serial communication with configurable speed. Asynchronous means there is no clock signal to synchronize the output bits from the transmitting device going to the receiving end.

Interface

UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (1)

The two signals of each UART device are named:

  • Transmitter (Tx)
  • Receiver (Rx)

The main purpose of a transmitter and receiver line for each device is to transmit and receive serial data intended for serial communication.

UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (2)

The transmitting UART is connected to a controlling data bus that sends data in a parallel form. From this, the data will now be transmitted on the transmission line (wire) serially, bit by bit, to the receiving UART. This, in turn, will convert the serial data into parallel for the receiving device.

The UART lines serve as the communication medium to transmit and receive one data to another. Take note that a UART device has a transmit and receive pin dedicated for either transmitting or receiving.

For UART and most serial communications, the baud rate needs to be set the same on both the transmitting and receiving device. The baud rate is the rate at which information is transferred to a communication channel. In the serial port context, the set baud rate will serve as the maximum number of bits per second to be transferred.

Table 1 summarizes what we must know about UART.

Table 1. UART Summary
Wires 2
Speed 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600, 1000000, 1500000
Methods of Transmission Asynchronous
Maximum Number of Masters 1
Maximum Number of Slaves 1

The UART interface does not use a clock signal to synchronize the transmitter and receiver devices; it transmits data asynchronously. Instead of a clock signal, the transmitter generates a bitstream based on its clock signal while the receiver is using its internal clock signal to sample the incoming data. The point of synchronization is managed by having the same baud rate on both devices. Failure to do so may affect the timing of sending and receiving data that can cause discrepancies during data handling. The allowable difference of baud rate is up to 10% before the timing of bits gets too far off.

Data Transmission

In UART, the mode of transmission is in the form of a packet. The piece that connects the transmitter and receiver includes the creation of serial packets and controls those physical hardware lines. A packet consists of a start bit, data frame, a parity bit, and stop bits.

UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (3)

Start Bit

The UART data transmission line is normally held at a high voltage level when it’s not transmitting data. To start the transfer of data, the transmitting UART pulls the transmission line from high to low for one (1) clock cycle. When the receiving UART detects the high to low voltage transition, it begins reading the bits in the data frame at the frequency of the baud rate.

UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (4)

Data Frame

The data frame contains the actual data being transferred. It can be five (5) bits up to eight (8) bits long if a parity bit is used. If no parity bit is used, the data frame can be nine (9) bits long. In most cases, the data is sent with the least significant bit first.

UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (5)

Parity

Parity describes the evenness or oddness of a number. The parity bit is a way for the receiving UART to tell if any data has changed during transmission. Bits can be changed by electromagnetic radiation, mismatched baud rates, or long-distance data transfers.

After the receiving UART reads the data frame, it counts the number of bits with a value of 1 and checks if the total is an even or odd number. If the parity bit is a 0 (even parity), the 1 or logic-high bit in the data frame should total to an even number. If the parity bit is a 1 (odd parity), the 1 bit or logic highs in the data frame should total to an odd number.

When the parity bit matches the data, the UART knows that the transmission was free of errors. But if the parity bit is a 0, and the total is odd, or the parity bit is a 1, and the total is even, the UART knows that bits in the data frame have changed.

UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (6)

Stop Bits

To signal the end of the data packet, the sending UART drives the data transmission line from a low voltage to a high voltage for one (1) to two (2) bit(s) duration.

UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (7)

Steps of UART Transmission

First: The transmitting UART receives data in parallel from the data bus.

UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (8)

Second: The transmitting UART adds the start bit, parity bit, and the stop bit(s) to the data frame.

UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (9)

Third: The entire packet is sent serially starting from start bit to stop bit from the transmitting UART to the receiving UART. The receiving UART samples the data line at the preconfigured baud rate.

UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (10)

Fourth: The receiving UART discards the start bit, parity bit, and stop bit from the data frame.

UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (11)

Fifth: The receiving UART converts the serial data back into parallel and transfers it to the data bus on the receiving end.

UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (12)

Frame Protocol

One key feature that is available in UART yet not fully used is the implementation of a frame protocol. The main use and importance of this is an added value for security and protection on each device.

For instance, when two devices use the same UART frame protocol, there are tendencies that, when connecting to the same UART without checking the configuration, the device will be connected to different pins that may cause malfunctions in the system.

On the other hand, implementing this ensures security because of the need to parse the information received in alignment with the design frame protocol. Each frame protocol is specifically designed to be unique and secure.

In designing a frame protocol, designers can set the desired headers and trailers, including CRC, to different devices. In Figure 13, two (2) bytes are set as part of the header.

Second: Under memory map, check the UART address.

UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (13)

Based on the sample, you can set a header, trailer, and CRC that are unique to your device.

Header 1 (H1 is 0xAB) and Header 2 (H2 is 0xCD)

Header is the unique identifier that determines if you are communicating with the correct device.

Command (CMD) Selection

Command will depend on the list of command designed to create the communication between two devices.

Data Length (DL) per Command

Data length will be based on the command chosen. You can maximize the length of data depending on the command chosen, so it can vary based on the selection. In that case, the data length can be adjusted.

Data n (Varying Data)

Data is the payload to be transferred from devices.

Trailer 1 (T1 is 0xE1) and Trailer 2 (T2 is 0xE2)

Trailers are data that are added after the transmission is ended. Just like the Header, they can be uniquely identified.

Cyclic Redundancy Checking (CRC Formula)

The cycling redundancy checking formula is an added error detecting mode to detect accidental changes to raw data. The CRC value of the transmitting device must always be equal to the CRC computations on the receiver’s end.

It is advisable to add security by implementing frame protocols for each UART device. The frame protocol needs identical configurations on both the transmitting and receiving devices.

UART Operations

When using any hardware communication protocol, it’s a prerequisite to check the data sheet and hardware reference manual.

Here are the steps to follow:

First: Check the data sheet interface of the device.

UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (14)
UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (15)

Third: Check the specific details for the UART PORT such as the operation mode, data bits length, the parity bit, and stop bits. Sample UART port details in data sheet: UART Port

The sample MCUs provide a full-duplex UART port, which is fully compatible with PC standard UARTs. The UART port provides a simplified UART interface to other peripherals or hosts, supporting full-duplex, DMA, and asynchronous transfer of serial data. The UART port includes support for five to eight data bits, and none, even, or odd parity. A frame is terminated by one and a half or two stop bits.

Fourth: Check the UART operation details, including the baud rate computation. Baud rate is configured using the following sample formula. This formula varies depending on the microcontroller.

Sample details of UART operations:

  • 5 to 8 data bits
  • 1, 2, or 1 and ½ stop bits
  • None, or even or odd parity
  • Programmable oversample rate by 4, 8, 16, 32
  • Baud rate = PCLK/((M + N/2048) × 2OSR + 2 × DIV

where,

OSR (oversample rate)

UART_LCR2.OSR = 0 to 3

DIV (baud rate divider)

UART_DIV = 1 to 65535

M (DIVM fractional baud rate M)

UART_FBR.DIVM = 1 to 3

N (DIVM fractional baud rate M)

UART_FBR.DIVN = 0 to 2047

Fifth: For the baud rate, make sure to check what peripheral clock (PCLK) to use. In this example, there is a 26 MHz PCLK and 16 MHz PCLK available. Notice that OSR, DIV, DIVM, and DIVN varies per device.

Table 2. Baud Rate Example Based on 26 MHz PCLK
Baud Rate OSR DIV DIVM DIVN
9600 3 24 3 1078
115200 3 4 1 1563
Table 3. Baud Rate Example Based on 16 MHz PCLK
Baud Rate OSR DIV DIVM DIVN
9600 3 17 3 1078
115200 3 2 2 348

Sixth: Next part is to check the detailed registers for UART Configuration. Take a look at the parameters in computing the baud rate such as UART_LCR2, UART_DIV, and UART_FBR. Table 4 will lead to a specific register to cover.

Table 4. UART Register Descriptions
Name Description
UART_DIV Baud rate divider
UART_FIBR Fractional baud rate
UART_LCR2 Second line control

Seventh: Under each register, check the details and substitute the values to compute for the baud rate, then start implementing the UART.

Why Is It Important?

Familiarity with the UART communication protocol is advantageous when developing robust, quality-driven products. Knowing how to send data using only two wires, as well as how to transport a whole pack of data or a payload, will help ensure that data is transferred and received without error. Since UART is the most commonly used hardware communication protocol, this knowledge can enable design flexibility in future designs.

Use Cases

You can use UART for many applications, such as:

  • Debugging: Early detection of system bugs is important during development. Adding UART can help in this scenario by capturing messages from the system.
  • Manufacturing function-level tracing: Logs are very important in manufacturing. They determine functionalities by alerting operators to what is happening on the manufacturing line.
  • Customer or client updates: Software updates are highly important. Having complete, dynamic hardware with update-capable software is important to having a complete system.
  • Testing/verification: Verifying products before they leave the manufacturing process helps deliver the best quality products possible to customers.

References

Basics of UART Communication.” Electronics Hub, July 2017.

Campbell, Scott. “Basics of UART Communication.” Circuit Basics. Keim, Robert.

Back to Basics: The Universal Asynchronous Receiver/ Transmitter.” All About Circuits, December 2016.

What Is UART Protocol? UART Communication Explained.” Arrow.

UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter (2024)

FAQs

What is the UART communication protocol? ›

What is UART? UART stands for universal asynchronous receiver / transmitter and defines a protocol, or set of rules, for exchanging serial data between two devices. UART is very simple and only uses two wires between transmitter and receiver to transmit and receive in both directions.

What is an example of a UART device? ›

A UART is usually an individual (or part of an) integrated circuit (IC) used for serial communications over a computer or peripheral device serial port. One or more UART peripherals are commonly integrated in microcontroller chips. Specialised UARTs are used for automobiles, smart cards and SIMs.

Is UART full or half duplex? ›

The UART component can be configured for Full Duplex, Half Duplex, RX only or TX only versions. All versions provide the same basic functionality differing only in the amount of resources utilized.

Which is the most commonly used UART? ›

Which is the most commonly used UART? Explanation: The Intel 8253, 8254 and 8259 are timers whereas Intel 8250 is a UART which is commonly used.

When would you use UART? ›

Embedded systems, microcontrollers, and computers mostly use UART as a form of device-to-device hardware communication protocol. Among the available communication protocols, UART uses only two wires for its transmitting and receiving ends.

Is UART a wireless communication? ›

UART modules integrated into Bluetooth devices enable wireless serial communication. These modules often come with Bluetooth stack implementations, allowing seamless wireless communication between devices.

Is UART a Bluetooth? ›

The Bluetooth UART service allows another device such as a smartphone to exchange any data it wants to with the micro:bit, in small chunks which are intended to be joined together.

How is UART used in mobile devices? ›

Universal asynchronous receiver/transmitter (UART) is a key player in the digital orchestra of computer, laptop, tablet, and smartphone communication. Acting like a linguistic bridge, UART enables these devices to exchange information seamlessly, ensuring your gadgets speak the same digital language.

Is UART used for USB? ›

UART to USB in Computers

UART devices were created to be compatible with this communication. USB, however, has almost completely replaced these outdated cables and connectors that operate using UART communication.

What port does UART use? ›

AKA Serial Port, RS-232, COM Port, RS-485. This type of functionality has been referred to by many different names: Serial Port, RS-232 Interface, COM Port, but the correct name is actually UART (Universal Asynchronous Receiver Transmitter).

What is the most common UART communication mode? ›

Asynchronous mode is the most common mode and is used for standard UART communication. Synchronous mode is used for higher-speed communication and requires a clock signal. ISO7816 mode is used for communication with smart cards and supports features such as parity checking and error detection.

Is UART a peer to peer? ›

UART is a peer-to-peer (P2P) hardware communication protocol where one end can be an MCU (microcontroller) and the other end can be another MCU, a sensor or a PC (through a USB-to-UART converter).

What are the disadvantages of UART? ›

Disadvantages of Using UART

The data frame size is limited to 9 bits. Multiple master and slave systems are not possible. To avoid data loss, each UART's Baud rate must be within 10% of one another. Data transfer speeds are slow.

How does UART work without a clock? ›

Instead of a clock signal, the transmitting UART adds start and stop bits to the data packet being transferred. These bits define the beginning and end of the data packet so the receiving UART knows when to start reading the bits.

What is the primary challenge associated with UART communication? ›

Limited data transfer speed: While UART can be slower than some protocols, it is not inherently limited; speeds can vary based on configuration. Lack of error detection mechanisms: UART does not have built-in error detection, which can be a significant challenge in ensuring data integrity.

What is UART communication between two devices? ›

In this communication, two different UART interact with each other using only two wires to transmit the data. UART at the transmitting part converts the parallel data from the controlling units into the serial form and then transmits it in serial to the receiving devices.

What are the benefits of UART communication? ›

Advantages of UART
  • It is bidirectional.
  • It is a full-duplex.
  • There is no clock signal because it is asynchronous.
  • Error checking using parity bit.
  • Data format and transmission speeds are configurable.
  • As long as both sides are set up for it, the structure of the data packet can be changed.
Mar 26, 2024

What is the difference between UART and RS232 protocol? ›

UART is the peripheral that can output asynchronous serial data frames like for RS232. RS232 is a communication standard that includes voltage levels and connector descriptions in addition to description of the serial data frames. RS232 has more signals than just RX and TX.

What is the difference between UART and I2C communication? ›

I2C is also generally faster than UART, and can reach speed of up to 3.4 MHz. Some of the disadvantages of I2C include its increasing circuit complexity with additional master/slave setups, and is only able to operate in half-duplex, meaning data can only be transmitted in one direction at a time.

Top Articles
Best Brisket Rub Recipe - Homemade & Award Winning Recipes
Cauliflower Soup Recipe (+VIDEO) - The Girl Who Ate Everything
Spasa Parish
Rentals for rent in Maastricht
159R Bus Schedule Pdf
Sallisaw Bin Store
Black Adam Showtimes Near Maya Cinemas Delano
Espn Transfer Portal Basketball
Pollen Levels Richmond
11 Best Sites Like The Chive For Funny Pictures and Memes
Things to do in Wichita Falls on weekends 12-15 September
Momokun Leaked Controversy - Champion Magazine - Online Magazine
Maine Coon Craigslist
How Nora Fatehi Became A Dancing Sensation In Bollywood 
‘An affront to the memories of British sailors’: the lies that sank Hollywood’s sub thriller U-571
Tyreek Hill admits some regrets but calls for officer who restrained him to be fired | CNN
Haverhill, MA Obituaries | Driscoll Funeral Home and Cremation Service
Rogers Breece Obituaries
Ems Isd Skyward Family Access
Elektrische Arbeit W (Kilowattstunden kWh Strompreis Berechnen Berechnung)
Omni Id Portal Waconia
Kellifans.com
Banned in NYC: Airbnb One Year Later
Four-Legged Friday: Meet Tuscaloosa's Adoptable All-Stars Cub & Pickle
Model Center Jasmin
Ice Dodo Unblocked 76
Is Slatt Offensive
Labcorp Locations Near Me
Storm Prediction Center Convective Outlook
Experience the Convenience of Po Box 790010 St Louis Mo
Fungal Symbiote Terraria
modelo julia - PLAYBOARD
Poker News Views Gossip
Abby's Caribbean Cafe
Joanna Gaines Reveals Who Bought the 'Fixer Upper' Lake House and Her Favorite Features of the Milestone Project
Tri-State Dog Racing Results
Navy Qrs Supervisor Answers
Trade Chart Dave Richard
Lincoln Financial Field Section 110
Free Stuff Craigslist Roanoke Va
Wi Dept Of Regulation & Licensing
Pick N Pull Near Me [Locator Map + Guide + FAQ]
Crystal Westbrooks Nipple
Ice Hockey Dboard
Über 60 Prozent Rabatt auf E-Bikes: Aldi reduziert sämtliche Pedelecs stark im Preis - nur noch für kurze Zeit
Wie blocke ich einen Bot aus Boardman/USA - sellerforum.de
Infinity Pool Showtimes Near Maya Cinemas Bakersfield
Dermpathdiagnostics Com Pay Invoice
How To Use Price Chopper Points At Quiktrip
Maria Butina Bikini
Busted Newspaper Zapata Tx
Latest Posts
Article information

Author: Chrissy Homenick

Last Updated:

Views: 5496

Rating: 4.3 / 5 (54 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Chrissy Homenick

Birthday: 2001-10-22

Address: 611 Kuhn Oval, Feltonbury, NY 02783-3818

Phone: +96619177651654

Job: Mining Representative

Hobby: amateur radio, Sculling, Knife making, Gardening, Watching movies, Gunsmithing, Video gaming

Introduction: My name is Chrissy Homenick, I am a tender, funny, determined, tender, glorious, fancy, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.