Wiki

The most recent version of this page is a draft.DiffThis version is outdated by a newer approved version.DiffThis version (25 Mar 2019 15:15) is a draft.
Approvals: 0/1

This is an old revision of the document!


Debugging UART with the ADALM2000

Objective

The objective of this tutorial is to use the Pattern Generator and Logic Analyzer instruments provided by the ADALM2000 (M2K) board and the Scopy software toolset to visualize UART (Universal Asynchronous Receiver/Transmitter) transactions between two devices.

As an example we will use as second device the EVAL-ADICUP3029 microcontroller board and a software project that contains the communication module for UART, being able to receive data and transmit it back.

Background

Universal Asynchronous Receiver/Transmitter is a computer hardware device (physical circuit in a microcontroller or a stand-alone integrated circuit) for asynchronous serial communication in which the data format and transmission speeds are configurable. Its main purpose is to transmit and receive serial data, using only two wires to communicate between devices (TX and RX).

The UART transmit converts parallel data from a controlling device like a microcontroller into serial form, transmits it in serial to the UART receive, which then converts the serial data back into parallel data for the receiving device. Data flows from the TX pin of the UART transmit to the RX pin of the UART receive.

Figure 1. UART data flow between devices

UART transmits data asynchronously, which means there is no clock signal to synchronize the output of bits from the transmitting UART to the sampling of bits by the receiving UART. The UART transmit contains 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.

Figure 2. UART data frame

When the UART receive detects a start bit, it starts to read the incoming bits at a specific frequency known as the baud rate. Baud rate is the rate at which data is transferred, expressed in bits per second (bps). Both UARTs (Rx and Tx) must be configured at almost the same baud rate. The baud rate between the transmitting and receiving UARTs can only differ by about 10% before the timing mismatch occurs.

UART transmitted data is organized into packets. Each packet contains 1 start bit, 5 to 9 data bits (depending on the UART), an optional parity bit, and 1-2 stop bits.

Figure 3. UART Packet Configuration

The UART data transmission line is normally held at a high voltage level when no transmission is occurring. To start the transfer of data, the the transmission line is pulled from high to low. 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.

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 mismatched baud rates, long distance data transfers, etc. 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 bits in the data frame should total to an even number. If the parity bit is a 1 (odd parity), the 1 bits 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.

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 at least two bit durations.

Hardware Configuration

Figure 4. shows the hardware connection between M2K board and EVAL-ADICUP360 + EVAL-CN0411-ARDZ shield.

Figure 4. UART Debug Hardware Setup

university/courses/electronics/m2k-uart-debug.1553523306.txt.gz · Last modified: 25 Mar 2019 15:15 by Antoniu Miclaus