USB and UART are common communication interfaces utilized in embedded systems to send and receive data between devices. UART is considered to be one of the earliest communication interfaces applied to computers. The newer USB protocol, however, has replaced many UART systems, but both are still prevalent in the embedded industry. In this article, we will provide insight into both USB and UART communications and background on their relation.
When computers were first introduced, accessory devices such as mice and printers were often connected via cables to the serial port of the computer and adhered to a new standard of serial data communication called RS-232. 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. USB, a serial protocol that also adheres to the RS-232 standard, was introduced as a more advanced and standardized way for devices to communicate through handshaking, device detection, auto speed negotiation, etc. UART is still used today, but is primarily seen in GPS and Bluetooth modules, Arduino, and other microcontrollers.
We’ll provide some background on USB and UART communication interfaces to get a better idea of how they are similar and different.
UART, or Universal Asynchronous Receiver/Transmitter, is a hardware communication protocol that uses asynchronous serial communication with configurable speed. Asynchronous means it doesn’t use a clock signal to synchronize the output bits from the transmitting UART to the sampling bits on the receiving UART. UART is also considered to be “universal” because the parameters including transfer speed and data speed are configurable by the developer.
UART communication consists of two UART devices that communicate directly with each other. The UART on the sender device, or the transmitting UART, receives parallel data from the CPU (microprocessor or microcontroller) and converts it to serial data. This serial data is transmitted to the UART on the receiver device, or the receiving UART. The receiving UART converts the received serial data back to parallel data and sends it to the CPU.
In UART communication, only two wires are required for communication including the Transmitter (Tx) and Receiver (Rx) signals. Data flows from the Tx pin of the transmitting UART to the Rx pin of the receiving UART. Serial communication protocols such as RS-232, RS-422, or RS-485 are transmitted using UART.
UART data is sent over the bus in the form of a packet. A packet consists of a start bit, data frame, a parity bit, and stop bits. The parity bit is used as an error check mechanism to help ensure data integrity. Instead of using a clock, the receiving and transmitting UART need to be on the same baud rate which allows the system to know where and when the bits have been clocked.
USB, or Universal Serial Bus, is a host-scheduled, token-based serial bus protocol that was designed to replace the multitude of cables and connectors required to connect peripheral devices to a host computer and instead implement a more standardized connection. USB addresses many of the requirements needed for this to occur including being able to self-identify on the bus and being hot-plugged for plug-and-play capabilities.
For USB communication, there is a USB host, or the master device, that initiates all communication that occurs over the bus. This is typically a computer or other controller. The peripheral device, or the slave device, is connected to the host and is programmed to provide the host with the information required to successfully operate.
When a USB device is plugged into a host device, the device undergoes enumeration. During this stage, the host recognizes the device and assigns it a unique 7-bit address. The host then queries the device for its descriptors which contains specific information about the device.
Depending on this exchange of information, data is transmitted and received over the bus through different USB data packet fields and packet types, and different types of data transfers. More on the specifics for this can be found here.
There are various USB connector types that include specific pins that allow the cable and connector to perform certain functions. USB connectors consist of differential data pins (-, +) for data transfer, VBUS for bus voltage, ground, and shield pins.
USB also has various cable specifications that has been introduced over the years, each supporting its own data rate:
USB has become the preferred serial communication protocol between digital products like computers and peripheral devices as it can transmit data across longer cables and offers higher transmission rates. UART, however, is still is used today for certain applications and is often seen in older devices.
In order to bridge the gap between older and newer devices, developers may need to keep legacy transmission paths viable between USB and UART systems. A USB to UART converter is an integrated circuit used to send or receive serial data from a USB port into serial data that can be received or sent by a UART interface. This is a small device that plugs into your USB port and has at least ground, Rx and Tx outputs. It acts as a serial port to your computer and the computer sends data to this port where the module converts it to UART signals.
Total Phase offers various USB protocol analyzers to monitor and debug USB traffic in real time. Our line of Beagle USB Protocol Analyzers includes:
Beagle USB 12 Protocol Analyzer:The Beagle USB 12 Protocol Analyzer can non-intrusively monitor Full/Low Speed USB (12 Mbps/1.5 Mbps)
Beagle USB 480 Protocol Analyzer:The Beagle USB 480 Protocol Analyzer can non-intrusively monitor High-speed USB 2.0 (up to 480 Mbps) and offers class-level decoding. It is also possible to use our Beagle USB 480 Protocol Analyzer to monitor the RS-232 bus and capture UART data. Please see this blog for more information.
Beagle USB 480 Power Protocol Analyzer – Standard and Ultimate Editions:The Beagle USB 480 Power Protocol Analyzer – Standard and Ultimate Editions can non-intrusively monitor High-speed USB 2.0 (up to 480 Mbps) and offer class-level decoding. This tool provides real-time graphing of VBUS current and voltage values and allows for interactive and bi-directional correlation of current/voltage values with USB data. The Ultimate edition also allows for USB 2.0 advanced triggers.
Beagle USB 5000 v2 SuperSpeed Protocol Analyzer – Standard and Ultimate Editions:The Beagle USB 5000 v2 SuperSpeed Protocol Analyzer - Standard or Ultimate Editions can non-intrusively monitor USB 3.0 or USB 2.0 (up to 5 Gbps) and offers class-level decoding. The Standard and Ultimate Editions can perform USB 2.0 and USB 3.0 simple and advanced matching/triggering. For USB 3.0 advanced triggers, the Standard version allows for a single state with a single match per stream to be defined, while the Ultimate edition allows for up to eight states to be defined with three matches per stream per state.
For more information on how our USB protocol analyzers can help debug your own USB systems, please contact us at sales@totalphase.com.
Also, to learn more about the differences between UART and other protocols like I2C and SPI, please see following blogs: