AN0059.0: UART Flow Control

Similar documents
AN0059.1: UART Flow Control

EFM8 Laser Bee Family QSG110: EFM8LB1-SLSTK2030A Quick Start Guide

AN0018.0: Supply Voltage Monitoring

QSG144: CP2615-EK2 Quick-Start Guide

Humidity/Temp/Optical EVB UG

Software Release Note

AN0015.0: EFM32 and EZR32 Wireless

EFM32 Happy Gecko Family EFM32HG-SLSTK3400A Quick-Start Guide

UG345: Si72xx Eval Kit User's Guide

EFM8 Universal Bee Family EFM8UB2 Errata

AN999: WT32i Current Consumption

Date CET Initials Name Justification

QSG119: Wizard Gecko WSTK Quick-Start Guide

QSG123: CP2102N Evaluation Kit Quick- Start Guide

EFM32 Pearl Gecko Family QSG118: EFM32PG1 SLSTK3401A Quick- Start Guide

Translate HCSL to LVPECL, LVDS or CML levels Reduce Power Consumption Simplify BOM AVL. silabs.com Building a more connected world. Rev. 0.

SMBus. Target Bootloader Firmware. Master Programmer Firmware. Figure 1. Firmware Update Setup

QSG114: CPT007B SLEX8007A Kit Quick- Start Guide

EFM8 Busy Bee Family EFM8BB2-SLSTK2021A Quick Start Guide

AN976: CP2101/2/3/4/9 to CP2102N Porting Guide

QSG153: Micrium s μc/probe Tool Quick- Start Guide

UG274: Isolated USB Expansion Board User Guide

UG322: Isolated CAN Expansion Board User Guide

AN1143: Using Micrium OS with Silicon Labs Thread

AN125 INTEGRATING RAISONANCE 8051 TOOLS INTO THE S ILICON LABS IDE. 4. Configure the Tool Chain Integration Dialog. 1. Introduction. 2.

QSG159: EFM32TG11-SLSTK3301A Quick- Start Guide

Date CET Initials Name Justification

AN1117: Migrating the Zigbee HA Profile to Zigbee 3.0

AN888: EZR32 Quick Start Guide

EFR32MG13, EFR32BG13 & EFR32FG13 Revision C and Data Sheet Revision 1.0

CP2110-EK CP2110 EVALUATION KIT USER S GUIDE. 1. Kit Contents. 2. Relevant Documentation. 3. Software Setup

QSG107: SLWSTK6101A Quick-Start Guide

UG369: Wireless Xpress BGX13P SLEXP8027A Kit User's Guide

AN1095: What to Do When the I2C Master Does Not Support Clock Stretching

AN0042: USB/UART Bootloader

The process also requires the use of the following files found in the Micriµm Quick Start Package for the FRDM-KL46Z:

CP2103-EK CP2103 EVALUATION KIT USER S GUIDE. 1. Kit Contents. 2. Relevant Documentation. 3. Software Setup USBXpress Driver Development Kit

CP2104-EK CP2104 EVALUATION KIT USER S GUIDE. 1. Kit Contents. 2. Relevant Documentation. 3. Software Setup USBXpress Driver Development Kit

Bluegiga WF111 Software Driver Release Notes

QSG155: Using the Silicon Labs Dynamic Multiprotocol Demonstration Applications

AN1139: CP2615 I/O Protocol

USBXpress Family CP2102N Errata

µc/probe on the Freescale FRDM-KL05Z without an RTOS

Date CET Initials Name Justification

EFM8 Universal Bee Family EFM8UB1 Errata

AN0018.1: Supply Voltage Monitoring

EFM32 EFM32GG11 Giant Gecko Family QSG149: EFM32GG11-SLSTK3701A Quick-Start Guide

CP2105-EK CP2105 EVALUATION KIT USER S GUIDE. 1. Kit Contents. 2. Relevant Documentation. 3. Software Setup USBXpress Driver Development Kit

AN1160: Project Collaboration with Simplicity Studio

Figure 1. CP2108 USB-to-Quad UART Bridge Controller Evaluation Board

CP2114 Family CP2114 Errata

AN1106: Optimizing Jitter in 10G/40G Data Center Applications

UG254: CP2102N-MINIEK Kit User's Guide

8-Bit MCU C8051F85x/86x Errata

UG294: CPT213B SLEXP8019A Kit User's Guide

Figure 1. Traditional Biasing and Termination for LVPECL Output Buffers

EFM8 Busy Bee EFM8BB1 Errata

Software Design Specification

UG271: CP2615-EK2 User's Guide

WT12 EVALUATION KIT DATA SHEET. Monday, 09 September Version 1.7

Router-E and Router-E-PA Wireless Router PRODUCT MANUAL

EFR32 Mighty Gecko Family EFR32MG1 with Integrated Serial Flash Errata History

AN1083: Creating and Using a Secure CoAP Connection with ARM s mbed TLS

AN888: EZR32 Simple TRX Application Quick Start Guide

EFM32 Zero Gecko EFM32ZG Errata

QSG107: SLWSTK6101A/B Quick-Start Guide

UG365: GATT Configurator User s Guide

Figure 1. Precision32 AppBuilder

UG313: Thunderboard Sense 2 Bluetooth Low Energy Demo User's Guide

ETRX3DVK Development Kit Quick-Start Guide

BRD4300B Reference Manual MGM111 Mighty Gecko Module

Software Design Specification

UG352: Si5391A-A Evaluation Board User's Guide

Si1146 UVIRSlider2EK Demo Kit

UG103.13: Application Development Fundamentals: RAIL

QSG107: SLWSTK6101A/B Quick-Start Guide

UG232: Si88xxxISO-EVB User's Guide

Wireless Development Suite (WDS) is a software utility used to configure and test the Silicon Labs line of ISM band RFICs.

EFM32G Product Revision E

FM-DAB-DAB Seamless Linking I2S SRAM. I2C / SPI Host Interface. FLASH Interface MOSI/SDA INTB MISO/A0 RSTB SCLK/SCL SSB/A1 SMODE

Si7005USB-DONGLE. EVALUATION DONGLE KIT FOR THE Si7005 TEMPERATURE AND HUMIDITY SENSOR. 1. Introduction. 2. Evaluation Kit Description

AN706: EZSP-UART Host Interfacing Guide

2. Key Points. F93x F92x F91x F90x. Figure 1. C8051F93x-C8051F90x MCU Family Memory Size Options

QSG166: WF200 Wi-Fi Development Kit Quick Start Guide

AGC. Radio DSP 1 ADC. Synth 0 AGC. Radio DSP 2 ADC. Synth 1. ARM Cortex M3 MCU. SPI/I2C Control Interface NVSSB SMODE SSB SCLK NVSCLK INTB

AN719 PRECISION32 IDE AND APPBUILDER DETAILED TUTORIAL AND WALKTHROUGH. 1. Introduction. Figure 1. Precision32 IDE and AppBuilder Walkthrough Overview

8-bit MCU Family C8051F93x/92x Errata

AN324 ADVANCED ENCRYPTION STANDARD RELEVANT DEVICES. 1. Introduction. 2. Implementation Potential Applications Firmware Organization

Software Design Specification

AN926: Reading and Writing Registers with SPI and I 2 C

Not Recommended for New Designs. Si Data Sheet Errata for Product Revision B

The Si50122-Ax-EVB is used to evaluate the Si50122-Ax. Table 1 shows the device part number and corresponding evaluation board part number.

UG366: Bluetooth Mesh Node Configuration User s Guide

AN1083: Creating and Using a Secure CoAP Connection with ARM s mbed TLS

EFM32 Pearl Gecko Family EFM32PG1 Errata

AN1006: Differences Between Si534x/8x Revision B and Revision D Silicon

μc/probe on the element14 BeagleBone Black

UG361: Si70xx Evaluation Tools User's Guide

UG103.7: Tokens Fundamentals

QSG126: Bluetooth Developer Studio Quick-Start Guide

Transcription:

This application note describes how to implement hardware or software flow control for UART. This application note includes the following: This PDF document Source files (zip) Example C-code Multiple IDE projects KEY POINTS UART Flow Control is a strategy for the communication bewteen slow and fast devices without data losing. Introduce the protocols of hardware flow control, legacy hardware flow control, and software flow control. UART hardware flow control is fully supported by UARTDRV, and UART software flow control is partially supported by the driver. Device A Device B silabs.com Building a more connected world. Rev. 1.03

Device Compatibility 1. Device Compatibility This application note supports multiple device families, and some functionality is different depending on the device. EFM32 MCU series 0 consists of: EFM32 Gecko (EFM32G) EFM32 Tiny Gecko (EFM32TG) EFM32 Giant Gecko (EFM32GG) EFM32 Leopard Gecko (EFM32LG) EFM32 Wonder Gecko (EFM32WG) EFM32 Zero Gecko (EFM32ZG) EFM32 Happy Gecko (EFM32HG) EZR32 Wireless MCU series 0 consists of: EZR32 Leopard Gecko (EZR32LG) EZR32 Wonder Gecko (EZR32WG) EZR32 Happy Gecko (EZR32HG) silabs.com Building a more connected world. Rev. 1.03 2

UART Flow Control Introduction 2. UART Flow Control Introduction UART Flow Control is a method for slow and fast devices to communicate with each other over UART without the risk of losing data. Consider the case where two units are communicating over UART. A transmitter T is sending a long stream of bytes to a receiver R. R is a slower device than T, and at some point R cannot keep up. It needs to either do some processing on the data or empty some buffers before it can keep receiving data. R needs to tell T to stop transmitting for a while. This is where flow control comes in. Flow control provides extra signaling to inform the transmitter that it should stop (pause) or start (resume) the transmission. Several forms of flow control exist. For example, hardware flow control uses extra wires, where the logic level on these wires define whether the transmitter should keep sending data or stop. With software flow control, special characters are sent over the normal data lines to start or stop the transmission. silabs.com Building a more connected world. Rev. 1.03 3

Flow Control Protocols 3. Flow Control Protocols This chapter describes the three most common ways to implement flow control. 3.1 Hardware Flow Control With hardware flow control (also called / flow control), two extra wires are needed in addition to the data lines. They are called (Request to Send) and (Clear to Send). These wires are cross-coupled between the two devices, so on one device is connected to on the remote device and vice versa. Each device will use its to output if it is ready to accept new data and read to see if it is allowed to send data to the other device. As long as a device is ready to accept more data, it will keep the line asserted. It will deassert some time before its receive buffer is full. There might still be data on the line and in the other device transmit registers which has to be received even after has been deasserted. The other device is required to respect the flow control signal and pause the transmission until is again asserted. Device A Device B Figure 3.1. Hardware Flow Control The flow control is bidirectional, meaning both devices can request a halt in transmission. If one of the devices never has to request a stop in transmission (i.e. it is fast enough to always receive data), the signal on the other device can be tied to the asserted logic level. The pin on the fast device can thus be freed up to other functions. 3.2 Legacy Hardware Flow Control A point of confusion when talking about hardware flow control is that the same names are used for different protocols. Hardware Flow Control sometimes refer to another method for flow control. In this document we shall refer to this second method as legacy Hardware Flow Control to differentiate it from the type discussed in 3.1 Hardware Flow Control. The name legacy is used because this method was actually the early method of implementing flow control. DTE DCE Figure 3.2. Legacy Hardware Flow Control Legacy Hardware Flow Control still uses two extra wires named and, but the functionality is slightly different. In this scheme the flow control is unidirectional and there is a master/slave relationship (traditionally the master and slave are referred to as DTE (Data Terminal Equipment) and DCE (Data Communications Equipment)). When the master wants to transmit data to the slave it asserts the line. The slave responds by asserting. Transmission can then occur until the slave deasserts, indicating that it needs a temporary halt in transmission. When the master has finished transmitting the entire message it will deassert. silabs.com Building a more connected world. Rev. 1.03 4

Flow Control Protocols 3.3 Software Flow Control Software flow control does not use extra wires. Only 3 wires are required (,, and ). Transmission is started and stopped by sending special flow control characters. The flow control characters are sent over the normal and lines. The flow control characters are typically the ASCII codes XON and XOFF (0x11 and 0x13). If device A sends XOFF to device B it means that B should halt transmission to A until B receives an XON character from A. silabs.com Building a more connected world. Rev. 1.03 5

Software Examples 4. Software Examples There are two kinds of examples provided regarding UART flow control. Examples with emlib and examples with emdrv (uartdrv). For each kind of example, users can select the demo for Hardware flow control, Software flow control using the PB1 button on the STK board, and pressing PB0 button to run the demo. The demo of Legacy hardware flow control master or Legacy hardware flow control slave are only included in the examples with emlib. The current demo name will be displayed on LCD. 4.1 Examples with emlib The software examples in this application note define an application interface to UART Flow Control. The interface is defined in uart_flow_control_s0.c and uart_flow_control_s0.h. The init function takes a configuration struct where several options can be specified, such as the pin location and polarity of the control signals. Two callback functions are specified. The callback will be called every time a byte is received. The callback is called when a full message has been sent. To send a message with flow control, use the function uartfcstarttx(). This method takes two parameters, a pointer to the message and the message length. The function will return immediately but start sending the message using interrupts. Transmission will automatically be turned on or off depending on the flow control signals. When the entire message has been sent, the callback routine is called. 4.1.1 UART Hardware Flow Control This example uses HW Flow control between two EFM32's to send dummy messages back and forth. At regular intervals the program will send a long message and continually listen for messages. At some defined buffer level the program will disable the transmission by deasserting. It keeps deasserted for some time to simulate a slow device. Figure 4.1. Hardware Flow Control Example Hardware Flow Control Example: After a certain time the receiver deasserts and the transmitter responds by pausing transmission. To test the application connect two EFM32's according to Figure 3.1 Hardware Flow Control on page 4. 4.1.2 UART Software Flow Control This example uses SW Flow control between two EFM32's to send dummy messages back and forth. At regular intervals the program will send a long message and continually listen for messages. At some defined buffer level the program will disable the transmission by sending XOFF, and send the XON to restart the transmission after processing the received data done. 4.1.3 Legacy HW Flow Control This example works in the same way as the UART Flow Control Example, except that the Legacy Hardware Flow Control Scheme is now used. To test the application, download the example to EFM32 devices, and select master mode for one EFM32 and slave mode for another. Then connect the two according to Figure 3.2 Legacy Hardware Flow Control on page 4. 4.2 Examples with emdrv The UART driver supports the UART capabilities of the USART, UART, and LEUART peripherals. The driver is fully reentrant, and multiple driver instances can coexist. The driver does not buffer or queue data, but it queues UART transmit and receive operations. Both blocking and non-blocking transfer functions are available. Non-blocking transfer functions report transfer completion with callback functions. Transfers are done using DMA. UART hardware flow control (/) is fully supported by the UART driver. However, UART software flow control (XON/XOFF) is partially supported by the driver. The application must monitor buffers and make decisions on when to send XON/ XOFF. Also the application should monitor the received data to pause or resume the transmission after receiving the flow control character XOFF or XON. silabs.com Building a more connected world. Rev. 1.03 6

Software Examples 4.2.1 UART Hardware Flow Control This example uses HW Flow control which is supported by the UART driver. At regular intervals the program will send a long message and then start to listen for messages until a message is received with the specific length. The UART driver will assert to start to receive new data, and deassert after receiving is complete. Also the UART driver will read before sending data to see if it is allowed to send data to the other device. To test the application connect two EFM32's according to Figure 3.1 Hardware Flow Control on page 4, or use the terminal with a USBto-UART bridge. After setting up the serial port with hardware flow control according to the figures as below, type 20 characters, and then the EFM32 will send a 52 bytes message. Figure 4.2. Setup the Serial Port silabs.com Building a more connected world. Rev. 1.03 7

Software Examples Figure 4.3. Test the Hardware Flow Control silabs.com Building a more connected world. Rev. 1.03 8

Software Examples 4.2.2 UART Software Flow Control UART software flow control (XON/XOFF) is partially supported by the driver, the application should monitor the received data during the data transmission, and pause or resume the transmitter after receiving XOFF or XON. To test the application connect two EFM32's or use the terminal with a USB-to-UART bridge. After setting up the serial port with software flow control according to the figure as below, type 20 characters, and then the EFM32 will send a 52 bytes message. Figure 4.4. Setup the Serial Port silabs.com Building a more connected world. Rev. 1.03 9

Revision History 5. Revision History Revision 1.03 January, 2017 Split AN0059 into AN0059.0 and AN0059.1 for MCU/Wireless Series 0 and MCU/Wireless Series 1, respectively. Added the "Device Compatibility" section. Added the "Examples with emdrv" section. Added support for all EFM32 Series 0 and EZR32 Series 0 devices. Re-organized the example code structure. Added software projects to demo how to implement the UART flow control by using UARTDRV. Revision 1.02 September, 2013 New cover layout Revision 1.01 May, 2013 Added software projects for ARM-GCC and Atollic TrueStudio. Revision 1.00 January, 2013 Initial revision. silabs.com Building a more connected world. Rev. 1.03 10

Smart. Connected. Energy-Friendly. Products www.silabs.com/products Quality www.silabs.com/quality Support and Community community.silabs.com Disclaimer Silicon Labs intends to provide customers with the latest, accurate, and in-depth documentation of all peripherals and modules available for system and software implementers using or intending to use the Silicon Labs products. Characterization data, available modules and peripherals, memory sizes and memory addresses refer to each specific device, and "Typical" parameters provided can and do vary in different applications. Application examples described herein are for illustrative purposes only. Silicon Labs reserves the right to make changes without further notice and limitation to product information, specifications, and descriptions herein, and does not give warranties as to the accuracy or completeness of the included information. Silicon Labs shall have no liability for the consequences of use of the information supplied herein. This document does not imply or express copyright licenses granted hereunder to design or fabricate any integrated circuits. The products are not designed or authorized to be used within any Life Support System without the specific written consent of Silicon Labs. A "Life Support System" is any product or system intended to support or sustain life and/or health, which, if it fails, can be reasonably expected to result in significant personal injury or death. Silicon Labs products are not designed or authorized for military applications. Silicon Labs products shall under no circumstances be used in weapons of mass destruction including (but not limited to) nuclear, biological or chemical weapons, or missiles capable of delivering such weapons. Trademark Information Silicon Laboratories Inc., Silicon Laboratories, Silicon Labs, SiLabs and the Silicon Labs logo, Bluegiga, Bluegiga Logo, Clockbuilder, CMEMS, DSPLL, EFM, EFM32, EFR, Ember, Energy Micro, Energy Micro logo and combinations thereof, "the world s most energy friendly microcontrollers", Ember, EZLink, EZRadio, EZRadioPRO, Gecko, ISOmodem, Micrium, Precision32, ProSLIC, Simplicity Studio, SiPHY, Telegesis, the Telegesis Logo, USBXpress, Zentri and others are trademarks or registered trademarks of Silicon Labs. ARM, CORTEX, Cortex-M3 and THUMB are trademarks or registered trademarks of ARM Holdings. Keil is a registered trademark of ARM Limited. All other products or brand names mentioned herein are trademarks of their respective holders. Silicon Laboratories Inc. 400 West Cesar Chavez Austin, 78701 USA http://www.silabs.com