AN0059.1: UART Flow Control

Similar documents
AN0059.0: UART Flow Control

QSG144: CP2615-EK2 Quick-Start Guide

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

Software Release Note

QSG123: CP2102N Evaluation Kit Quick- Start Guide

EFM8 Universal Bee Family EFM8UB2 Errata

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

UG345: Si72xx Eval Kit User's Guide

QSG119: Wizard Gecko WSTK Quick-Start Guide

Date CET Initials Name Justification

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

AN999: WT32i Current Consumption

EFM32 Happy Gecko Family EFM32HG-SLSTK3400A Quick-Start Guide

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

EFM8 Busy Bee Family EFM8BB2-SLSTK2021A Quick Start Guide

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

AN1143: Using Micrium OS with Silicon Labs Thread

UG274: Isolated USB Expansion Board User Guide

Humidity/Temp/Optical EVB UG

UG369: Wireless Xpress BGX13P SLEXP8027A Kit User's Guide

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

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

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

QSG155: Using the Silicon Labs Dynamic Multiprotocol Demonstration Applications

UG254: CP2102N-MINIEK Kit User's Guide

Date CET Initials Name Justification

UG322: Isolated CAN Expansion Board User Guide

QSG107: SLWSTK6101A Quick-Start Guide

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

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

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

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

AN1117: Migrating the Zigbee HA Profile to Zigbee 3.0

USBXpress Family CP2102N Errata

EFM8 Universal Bee Family EFM8UB1 Errata

AN0018.1: Supply Voltage Monitoring

Bluegiga WF111 Software Driver Release Notes

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

QSG159: EFM32TG11-SLSTK3301A Quick- Start Guide

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

AN1139: CP2615 I/O Protocol

BRD4300B Reference Manual MGM111 Mighty Gecko Module

Date CET Initials Name Justification

AN1160: Project Collaboration with Simplicity Studio

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

CP2114 Family CP2114 Errata

UG271: CP2615-EK2 User's Guide

EFR32 Mighty Gecko Family EFR32MG1 with Integrated Serial Flash Errata History

UG294: CPT213B SLEXP8019A Kit User's Guide

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

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

8-Bit MCU C8051F85x/86x Errata

UG103.13: Application Development Fundamentals: RAIL

EFM8 Busy Bee EFM8BB1 Errata

QSG107: SLWSTK6101A/B Quick-Start Guide

Figure 1. Traditional Biasing and Termination for LVPECL Output Buffers

Si1146 UVIRSlider2EK Demo Kit

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

Software Design Specification

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

AN706: EZSP-UART Host Interfacing Guide

Figure 1. Precision32 AppBuilder

UG365: GATT Configurator User s Guide

ETRX3DVK Development Kit Quick-Start Guide

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

Software Design Specification

AN888: EZR32 Quick Start Guide

QSG107: SLWSTK6101A/B Quick-Start Guide

AN0018.0: Supply Voltage Monitoring

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup using a USB Debug Adapter

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

EFM32 Zero Gecko EFM32ZG Errata

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

UG352: Si5391A-A Evaluation Board User's Guide

UG232: Si88xxxISO-EVB User's Guide

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

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

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

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup Using a USB Debug Adapter

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

QSG166: WF200 Wi-Fi Development Kit Quick Start Guide

QSG126: Bluetooth Developer Studio Quick-Start Guide

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup Using a USB Debug Adapter

EFM32 Pearl Gecko Family EFM32PG1 Errata

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

Si1140-DK. Si1140 DEVELOPMENT KIT USER S GUIDE. 1. Kit Contents. Figure 1. Si1143 Evaluation Board

TS9004 Demo Board FEATURES ORDERING INFORMATION

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

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

AN0015.0: EFM32 and EZR32 Wireless

Software Design Specification

8-bit MCU Family C8051F93x/92x Errata

AN1119: Using RAIL for Wireless M-Bus Applications with EFR32

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

μc/probe on the element14 BeagleBone Black

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

UG361: Si70xx Evaluation Tools User's Guide

Transcription:

AN0059.1: UART Flow Control 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 and software flow control. The hardware flow control is natively supported by the EFM32 and Wireless SoC Series 1 family USART peripheral. UART hardware flow control is fully supported by UARTDRV, and UART software flow control is partially supported by the driver. Device A TX RX TX RX Device B CTS RTS GND CTS RTS GND 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 Series 1 (EFM32xG1/EFM32xG12) consists of: EFM32 Pearl Gecko (EFM32PG1/EFM32PG12) EFM32 Jade Gecko (EFM32JG1/EFM32JG12) EFR32 Wireless MCU Series 1 (EFR32xG1/EFR32xG12/EFR32xG13/EFR32xG14) consists of: EFR32 Blue Gecko (EFR32BG1/EFR32BG12/EFR32BG13) EFR32 Flex Gecko (EFR32FG1/EFR32FG12/EFR32FG13/EFR32FG14) EFR32 Mighty Gecko (EFR32MG1/EFR32MG12/EFR32MG13) 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 most common ways to implement flow control. 3.1 Hardware Flow Control With hardware flow control (also called RTS/CTS flow control), two extra wires are needed in addition to the data lines. They are called RTS (Request to Send) and CTS (Clear to Send). These wires are cross-coupled between the two devices, so RTS on one device is connected to CTS on the remote device and vice versa. Each device will use its RTS to output if it is ready to accept new data and read CTS 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 RTS line asserted. It will deassert RTS 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 RTS has been deasserted. The other device is required to respect the flow control signal and pause the transmission until RTS is again asserted. Device A TX RX CTS RTS GND TX RX CTS RTS GND 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 CTS signal on the other device can be tied to the asserted logic level. The RTS pin on the fast device can thus be freed up to other functions. The hardware flow control is natively supported by the EFM32 and Wireless SoC Series 1 family. Use RTSPEN and CTSPEN in USARTn_ROUTEPEN to allocate the hardware flow control to GPIOs. RTS is an outgoing signal which indicates that RX buffer space is available to receive a frame. The link partner is being requested to send its data when RTS is asserted. CTS is an incoming signal to stop the next TX data from going out. When CTS is negated, the frame currently being transmitted is completed before stopping. CTS indicates that the link partner has RX buffer space available, and the local transmitter is clear to send. Also use CTSEN in USARTn_CTLX to enable the CTS input into the TX sequencer. 3.2 Software Flow Control Software flow control does not use extra wires. Only 3 wires are required (RX, TX, and GND). Transmission is started and stopped by sending special flow control characters. The flow control characters are sent over the normal TX and RX 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 4

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 current demo name will be displayed on LCD. 4.1 Examples with emlib Since the hardware flow control be natively supported by USART peripheral, the init function will initialize the pin location of the flow control signals. The RTS and CTS is default low true, but the polarity can be inverted with RTSINV and CTSINV in USARTn_CTRLX. Two callback functions are specified. The RX callback will be called every time a byte is received. The TX 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 TX 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. The USART peripheral will deassert RTS pin on RX buffer full, and assert the RTS pin when the RX buffer space is available to receive a frame. When CTS is negated, the frame currently being transmitted is completed before stopping, and the next Tx data will be stopped. 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.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 (CTS/RTS) 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 5

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 USART peripheral will deassert RTS pin on RX buffer full, and assert RTS pin when the RX buffer space is available to receive a frame. When CTS is negated, the frame currently being transmitted is completed before stopping, and the next Tx data will be stopped. 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.1. Setup the Serial Port silabs.com Building a more connected world. Rev. 1.03 6

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

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.3. Setup the Serial Port silabs.com Building a more connected world. Rev. 1.03 8

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 EFM32 Series 1 and EFR32 Series 1 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 9

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, TX 78701 USA http://www.silabs.com