Wiki

The most recent version of this page is a draft.DiffThis version is outdated by a newer approved version.DiffThis version (26 Mar 2019 13:39) 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-ADICUP3029.

Figure 4. UART Debug Hardware Setup

The UART pins for the EVAL-ADICUP3029 are available for communication at port P7.

EVAL-ADICUP3029 UART pin configuration: PORT P7:

  • Pin7 - UART TX
  • Pin8 - UART RX

PORT P4:

  • Pin7 - GND

M2K UART pin configuration:

  • DIO0 - TX
  • DIO1 - RX
  • GND - DGND

Connect M2K pins to EVAL-ADICUP3029 as follows:

  • Pin7 - DIO1
  • Pin8 - DIO0

Scopy Pattern Generator Configuration

First, we need to setup the Pattern Generator that will be used to transmit data to EVAL-ADICUP3029.

The EVAL-ADICUP3029 software application has the UART configured as follows:

  • Baud rate: 115200
  • Stop bits: 1
  • Parity: none

For transmission, we will use only one digital channel as Tx. Open the Pattern Generator instrument, select DIO0 channel and press “Group with Selected” button. This will display the decoded pattern for our application based on the data that we want to send.

On the left side of the user interface, a settings menu is available. Configure the UART settings to match the software application that we want to debug.

An example for the Pattern Generator setup is presented in Figure 5.

Figure 5. UART Pattern Generator Setup

Pattern Generator settings:

  • Pattern: UART
  • Baud: 115200
  • Stop bits: 1
  • Parity: None
  • Data to send: 'A' (ASCII code)

Scopy Logic Analyzer Configuration

Several SPI configuration parameters need to be determined in order to properly configure Scopy. For the EVAL-ADICUP3029 project, they are as follows:

  • Baud rate: 115200
  • Data bits: 8
  • Parity: none (Check polarity: no)
  • Stop bits: 1
  • Bit order: LSB first
  • Data format: ASCII

An overview of the user interface is shown in Figure 6.

Figure 6. UART Logic Analyzer User Interface

Open the Logic Analyzer instrument, select DIO0-DIO1 lines and press the “Group with selected” button.

Select the channel group formed and apply the UART decoder. While the group is selected, open settings menu by pressing the button on the top right side of the user interface. A settings panel will appear for the UART decoder, allowing the signal-channel configuration and parameters setup. Apply the parameters listed above to the group.

Figure 7. UART Group Settings

The Logic Analyzer must be set up to “catch” the UART packet transfer on the Logic Analyzer plot. Therefore we need to configure a trigger. Since the UART transfer starts when the start bit is detected (transmission line is pulled from high to low), we need to trigger the falling edge of the transmission channel.

Figure 8. Trigger Settings

UART Example

This example verifies the receive/transmit operations of the software application developed for EVAL-ADICUP3029. The data will be transmitted from the Pattern Generator, and visualized on Logic Analyzer, by connecting ADALM2000 to the UART pins of the EVAL-ADICUP3029 board (see Hardware Configuration step).

Set the Time Base of the Logic Analyzer instrument to 30us and the Trigger Position at 90us and run a Single sweep.

Figure 9. General Settings

university/courses/electronics/m2k-uart-debug.1553603954.txt.gz · Last modified: 26 Mar 2019 13:39 by Antoniu Miclaus