Wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
university:courses:electronics:m2k-uart-debug [03 Apr 2019 14:40] – [Background] Antoniu Miclausuniversity:courses:electronics:m2k-uart-debug [21 May 2019 19:27] – [Hardware Configuration] formatting Mark Thoren
Line 5: Line 5:
 The objective of this tutorial is to use the Pattern Generator and Logic Analyzer instruments provided by the [[adi>ADALM2000]] (M2K) board and the [[university:tools:m2k:scopy|Scopy]] software toolset to visualize UART (Universal Asynchronous Receiver/Transmitter) transactions between two devices. The objective of this tutorial is to use the Pattern Generator and Logic Analyzer instruments provided by the [[adi>ADALM2000]] (M2K) board and the [[university:tools:m2k:scopy|Scopy]] software toolset to visualize UART (Universal Asynchronous Receiver/Transmitter) transactions between two devices.
  
-As an example we will use as second device the [[adi>EVAL-ADICUP3029]] microcontroller board and a software project that contains the communication module for UARTbeing able to receive data and transmit it back.+The [[adi>EVAL-ADICUP3029]] microcontroller board and a typical software project that uses the UART communication module, waits for input data from the user, and then echoes it back through the pins available on the board.
  
 ===== Background ==== ===== 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).+Universal Asynchronous Receiver/Transmitter (UART) is a computer hardware device for asynchronous serial communication in which the data format and transmission speeds are configurable. Its purpose is to transmit and receive serial data, using only two wires to communicate between devices (TX and RX). In the past, UARTs were separate integrated circuits, such as the industry standard 16550. However, most modern microcontrollers include one or more UART peripheral devices on-chip, requiring only an external physical interface device, such as a line driver / receiver or USB-UART interface device.
  
-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.+The UART transmitter converts parallel data from a controlling device like a microcontroller into serial form, transmits it in serial to the UART receiver, which then converts the serial data back into parallel data for the receiving device. Data flows from the TX pin of the UART transmitter to the RX pin of the UART receiver.
  
 <WRAP centeralign>{{:university:courses:electronics:uart_flow.png?400|}}</WRAP> <WRAP centeralign>{{:university:courses:electronics:uart_flow.png?400|}}</WRAP>
 <WRAP centeralign>Figure 1. UART data flow between devices</WRAP> <WRAP centeralign>Figure 1. UART data flow between devices</WRAP>
  
-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.+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 frame the data byte being transferred. These bits define the beginning and end of the data byte so the receiving UART knows when to start (and stop) reading the bits.
  
 {{:university:courses:electronics:uart_frame.png|}} {{:university:courses:electronics:uart_frame.png|}}
 <WRAP centeralign>Figure 2. UART data frame</WRAP> <WRAP centeralign>Figure 2. UART data frame</WRAP>
  
-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.+When the UART receiver detects a start bit, it starts to read the incoming bits at a specific frequency, called 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. This scheme is tolerant of a slight mismatch in baud rate between the transmitting and receiving devices; a typical 8-bit byte can tolerate approximately 10% difference in baud rate between transmitter and receiver before a bit error 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.+UART data is organized into bytes. Each byte contains 1 start bit, 5 to 9 data bits (depending on the UART), an optional parity bit, and 1 or 2 stop bits.
  
 <WRAP centeralign>{{:university:courses:electronics:uart_sequence.png?700|}}</WRAP> <WRAP centeralign>{{:university:courses:electronics:uart_sequence.png?700|}}</WRAP>
-<WRAP centeralign> Figure 3. UART Packet Configuration </WRAP>+<WRAP centeralign> Figure 3. UART Byte Configuration </WRAP>
  
-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. +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 interprets this event as as start bit and begins reading the rest of the bits in the data frame at the selected 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+A parity bit may be included after the data bits. Parity describes the evenness or oddness of a number.
  
 Even parity: for a given set of bits, the occurrences of bits whose value is 1 is counted. If that count is odd, the parity bit value is set to 1. If the count of 1s in a given set of bits is already even, the parity bit value is 0. Even parity: for a given set of bits, the occurrences of bits whose value is 1 is counted. If that count is odd, the parity bit value is set to 1. If the count of 1s in a given set of bits is already even, the parity bit value is 0.
Line 36: Line 36:
 Odd parity: for a given set of bits, if the count of bits with a value of 1 is even, the parity bit value is set to 1 . If the count of bits with a value of 1 is odd, the count is already odd so the parity bit value is 0.  Odd parity: for a given set of bits, if the count of bits with a value of 1 is even, the parity bit value is set to 1 . If the count of bits with a value of 1 is odd, the count is already odd so the parity bit value is 0. 
  
-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.+The parity bit is simple error detection scheme, and will detect all single-bit errors. Bits can be changed during transmission by mismatched baud rates, noise picked up on long distance data transfers, etc. Like baud rate, both transmitter and receiver must be set to the same parity configuration. 
 + 
 +To signal the end of the data byte, the sending UART drives the data transmission line from a low voltage to a high voltage for at least two bit periods.
  
 ===== Hardware Configuration ==== ===== Hardware Configuration ====
Line 64: Line 66:
   * Pin7 - DIO1   * Pin7 - DIO1
   * Pin8 - DIO0   * Pin8 - DIO0
 +
 +**EVAL-ADICUP3029 UART switch configuration:**
 +
 +  * Set S2 to the CENTER position.
 +
 +(S2 selects which device to connect the ADuCM3029's UART to - USB-UART interface, Arduino headers, or WiFi module connector.)
 +
 +===== Software Configuration ====
 +
 +There are several options for which software to use for this demonstration; the main requirement is that it implement some sort of command-line interface that echoes characters back as they are typed. The CLI example project for the EVAL-ADICUP3029 can be used:
 +
 +[[https://github.com/analogdevicesinc/EVAL-ADICUP3029/tree/master/projects/ADuCM3029_demo_cli|CLI example for ADICUP3029]]
 +
 +
  
 ===== Scopy Pattern Generator Configuration ==== ===== Scopy Pattern Generator Configuration ====
  
-First, we need to setup the Pattern Generator that will be used to transmit data to EVAL-ADICUP3029.+First, set up the Pattern Generator to transmit test data to EVAL-ADICUP3029.
  
 The EVAL-ADICUP3029 software application has the UART configured as follows: The EVAL-ADICUP3029 software application has the UART configured as follows:
Line 113: Line 129:
 <WRAP centeralign> Figure 7. UART Group Settings </WRAP> <WRAP centeralign> Figure 7. UART Group Settings </WRAP>
  
-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.+The Logic Analyzer must be set up to “catch” the UART byte transfer on the Logic Analyzer plot. Since the UART transfer starts with a start bit(transmit line is pulled from high to low), we can use this event to trigger the capture.
  
 <WRAP centeralign>{{:university:courses:electronics:uart_trigger_grp.png|}}</WRAP> <WRAP centeralign>{{:university:courses:electronics:uart_trigger_grp.png|}}</WRAP>
Line 131: Line 147:
 The Logic Analyzer will wait for the falling edge of the Rx signal to be triggered (corresponding to the start bit).  The Logic Analyzer will wait for the falling edge of the Rx signal to be triggered (corresponding to the start bit). 
  
-Run a single sweep on the Pattern Generator to send the first UART packet.+Run a single sweep on the Pattern Generator to send the first UART byte.
  
 The result captured by the Logic Analyzer is presented in Figure 10. The result captured by the Logic Analyzer is presented in Figure 10.
Line 149: Line 165:
 <WRAP centeralign>Figure 11. Pattern Generator - Data to send</WRAP> <WRAP centeralign>Figure 11. Pattern Generator - Data to send</WRAP>
  
-On the Logic Analyzer, adjust accordingly the Time Base and Trigger Position to be able to see all the transactions. (i.e. Time Base: 100us and Trigger Position: 300us)+On the Logic Analyzer, adjust the Time Base and Trigger Position accordingly to be able to see all of the transactions. (i.e. Time Base: 100us and Trigger Position: 300us)
  
 Run Single sweep in The Logic Analyzer and then in the Pattern Generator. Run Single sweep in The Logic Analyzer and then in the Pattern Generator.
  
-The result captured by the Logic Analyzer is presented in Figure 12.+The result captured by the Logic Analyzer is shown in Figure 12.
  
 <WRAP centeralign>{{:university:courses:electronics:uart_la_plot2.png|}}</WRAP> <WRAP centeralign>{{:university:courses:electronics:uart_la_plot2.png|}}</WRAP>
 <WRAP centeralign>Figure 11. Pattern Generator - Data to send</WRAP> <WRAP centeralign>Figure 11. Pattern Generator - Data to send</WRAP>
  
-As expected all the data bytes were received by the EVAL-ADICUP3029 board and sent back on Tx pin. Each byte is sent back as soon as the receive action for one byte is finished.+The EVAL-ADICUP3029 example program echoes received data bytes as they come in.  As expected all the data bytes were received by the EVAL-ADICUP3029 board and sent back on Tx pin.
  
 =====Conclusion===== =====Conclusion=====
university/courses/electronics/m2k-uart-debug.txt · Last modified: 03 Jan 2021 22:21 by Robin Getz