13.07.2015 Views

Low Energy UART - AN0017 - Application Note - Energy Micro

Low Energy UART - AN0017 - Application Note - Energy Micro

Low Energy UART - AN0017 - Application Note - Energy Micro

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

...the world's most energy friendly microcontrollers<strong>Low</strong> <strong>Energy</strong> <strong>UART</strong><strong>AN0017</strong> - <strong>Application</strong> <strong>Note</strong>IntroductionThis application note demonstrates how to use the <strong>Low</strong> <strong>Energy</strong> <strong>UART</strong> (LE<strong>UART</strong>)module on the EFM32 microcontrollers. The LE<strong>UART</strong> is able to run full <strong>UART</strong>communication even when the device is in deep sleep mode EM2. Together withintelligent interrupt functions and flexible DMA integration, this enables simple andenergy friendly communication .This application note includes:• This PDF document• Source files (zip)• Example C-code• Multiple IDE projects


1 LE<strong>UART</strong> Theory...the world's most energy friendly microcontrollers1.1 General theoryThe EFM32 LE<strong>UART</strong> is a unique <strong>Low</strong> <strong>Energy</strong> <strong>UART</strong> that offers two-way communication on a very strictpower budget. Only a 32.768 kHz clock source is needed to allow <strong>UART</strong> communication up to 9600 baud/s. This means that the EFM32 LE<strong>UART</strong> can operate in deep sleep mode EM2, and wait for an incoming<strong>UART</strong> frame while consuming extremely little energy. When a <strong>UART</strong> frame is completely received by theLE<strong>UART</strong>, the CPU can quickly be woken up. Alternatively, multiple frames can be transferred to memoryby the DMA before waking up the CPU. The EFM32 LE<strong>UART</strong> also incorporates functionality to handlehigher level communication protocols, e.g. the option to block incoming frames until a configurable startframe is detected, and to detect a configurable signal frame (to indicate e.g. the end of a transmission).In the same way as received, data can be transmitted in EM2 either on frame by frame basis with datadirectly from the CPU, or in larger groups of frames trough the DMA. The EFM32 LE<strong>UART</strong> includes allneeded hardware support to make asynchronous serial communication possible with minimum softwareinterference, while consuming extremely small amounts of energy.The advantage of the LE<strong>UART</strong> is the ability to operate in EM2, while most other modules are turnedoff for energy conservation. The option to enable low energy serial communication, in combination withthe DMA's ability to read and write from memory without CPU intervention, offers wide functionality forsystem designers using the EFM32 in low energy applications.Figure 1.1. LE<strong>UART</strong> two link full duplex connectionTXRXRXTXLE<strong>UART</strong>PERIPHERALIC2013-05-08 - an0017_Rev1.07 2 www.energymicro.com


...the world's most energy friendly microcontrollers2.8 Half-Duplex OperationThe LE<strong>UART</strong> offers an option to locally loopback the transmitted data to the receive pin. This is usefulfor debugging, as the LE<strong>UART</strong> can receive the data it transmits, but it is also used to allow the LE<strong>UART</strong>to read and write to the same pin, which is required for some half duplex communication modes. Whendoing full duplex communication, two data links are provided, making it possible for data to be sentand received at the same time. In half duplex mode, data is only sent in one direction at a time. Thereare several possible half duplex setups. Both single and double data-links, or with an external driver.When communicating over a single data-link, the transmitter must be tristated whenever data is nottransmitted. The LE<strong>UART</strong> can automatically tristate the transmit pin whenever the transmitter is inactive,if the AUTOTRI pin in the LE<strong>UART</strong>n_CTRL register is set.2.9 GPIO and RoutingThe LE<strong>UART</strong> modules have the ability to route its TX and RX pins to some different predefined locationson the MCU pinout. The LE<strong>UART</strong>n_ROUTE register must be set to enable and route the pins to thedesired location.To enable the LE<strong>UART</strong> to interact with any external system components, like the RS232 port or anotherperipheral IC, the GPIO I/O pins must be configured accordingly. The GPIO has a variety of differentpin modes available, and in the supplied code examples the TX pins are configured as push-pull output.The RX pins are enabled as inputs with a pull-up. The pull-up helps to define the input state in case lineis not driven to a defined value by the other part. This can happen if you enable the RX module beforethe TX module. Refer to the application note "AN0012 GPIO" more examples on GPIO mode setting.2013-05-08 - an0017_Rev1.07 5 www.energymicro.com


3 Software Examples...the world's most energy friendly microcontrollersThe following software examples demonstrates a way to achieve full <strong>UART</strong> communication, using theLE<strong>UART</strong> functionality of the EFM32.3.1 Listening and Receiving in EM2.In this example, LE<strong>UART</strong> communication is initialized using the DMA to transfer received data fromthe LE<strong>UART</strong> receive register to the system memory. When a preconfigure signal frame is received, theLE<strong>UART</strong> generates a interrupt, and the CPU wakes up and writes all the received data from the memoryto the LCD.3.1.1 Example 1: Receiving on DVKThis DVK can receive data both trough RS232, and directly through the pinout on the Prototype Board.This means that the example can be run in a variety of different setups, receiving data both from anotherDVK, a STK or a PC trough the RS232 port on the DVK. The LE<strong>UART</strong>1 RX pin is located on pin J10 onthe DVK Prototype Board, and needs to be connected to the TX pin on the transmitting DVK or STK, ortrough a RS232 cable to a PC. <strong>Note</strong> that the sender and received must have same ground and supplyvoltage when connecting the RX and TX lines directly without using the RS232 port.3.1.2 Example 2: Receiving on STKOn the STK the data can be received trough the pinout located along the rim of the board. The LE<strong>UART</strong>1RX pin is located on the PC7 pin on the bottom row.3.2 Transmitting in EM2.In this example, LE<strong>UART</strong> communication is initialized using the DMA to transfer data from a locationin the local system memory to the LE<strong>UART</strong>, on given RTC(Real Time Clock) interrupts. Every othersecond, the RTC interrupt initializes the DMA to start feeding the LE<strong>UART</strong> TX transmit register with data,and returns to EM2. One of two predefined strings is then transmitted trough the LE<strong>UART</strong> to anyonelistening. The two strings will alternate.3.2.1 Example 3: Transmitting from DVKThe DVK can send data both directly through the pinouts on the Prototype board, and through the RS232port provided. The example can in this way be set up and run in several different setups, both transmittingto another DVK, a STK or a PC. The LE<strong>UART</strong>1 TX pin is located on the pin J9 on the DVK PrototypeBoard, and needs to be connected to the RX pin on any receiving device, or to a PC through the use ofa RS232 cable to a PC. <strong>Note</strong> that the sender and received must have same ground and supply voltagewhen connecting the RX and TX lines directly without using the RS232 port.3.2.2 Example 4: Transmitting from STKOn the STK the data can be transmitted through the pinout located along the rim of the board. TheLE<strong>UART</strong>1 TX pin is located on the PC6 pin on the bottom row.2013-05-08 - an0017_Rev1.07 6 www.energymicro.com


4 Revision History...the world's most energy friendly microcontrollers4.1 Revision 1.072013-05-08Added software projects for ARM-GCC and Atollic TrueStudio.4.2 Revision 1.062012-11-12Adapted software projects to new kit-driver and bsp structure.4.3 Revision 1.052012-08-13Adapted software projects to new peripheral library naming and CMSIS_V3.4.4 Revision 1.042011-11-15Updated transmit examples to use DMA callback to allow sleeping while transmitting.4.5 Revision 1.032011-10-21Updated IDE project paths with new kits directory.4.6 Revision 1.022011-05-18Updated projects to align with new bsp version4.7 Revision 1.012010-11-16Changed example folder structure, removed build and src folders.Updated chip init function to newest efm32lib version.Updated register defines in code to match newest efm32lib release.4.8 Revision 1.002010-09-24Initial revision.2013-05-08 - an0017_Rev1.07 7 www.energymicro.com


A Disclaimer and TrademarksA.1 Disclaimer...the world's most energy friendly microcontrollers<strong>Energy</strong> <strong>Micro</strong> AS intends to provide customers with the latest, accurate, and in-depth documentationof all peripherals and modules available for system and software implementers using or intending touse the <strong>Energy</strong> <strong>Micro</strong> products. Characterization data, available modules and peripherals, memorysizes and memory addresses refer to each specific device, and "Typical" parameters provided can anddo vary in different applications. <strong>Application</strong> examples described herein are for illustrative purposesonly. <strong>Energy</strong> <strong>Micro</strong> reserves the right to make changes without further notice and limitation to productinformation, specifications, and descriptions herein, and does not give warranties as to the accuracyor completeness of the included information. <strong>Energy</strong> <strong>Micro</strong> shall have no liability for the consequencesof use of the information supplied herein. This document does not imply or express copyright licensesgranted hereunder to design or fabricate any integrated circuits. The products must not be used withinany Life Support System without the specific written consent of <strong>Energy</strong> <strong>Micro</strong>. A "Life Support System"is any product or system intended to support or sustain life and/or health, which, if it fails, can bereasonably expected to result in significant personal injury or death. <strong>Energy</strong> <strong>Micro</strong> products are generallynot intended for military applications. <strong>Energy</strong> <strong>Micro</strong> products shall under no circumstances be used inweapons of mass destruction including (but not limited to) nuclear, biological or chemical weapons, ormissiles capable of delivering such weapons.A.2 Trademark Information<strong>Energy</strong> <strong>Micro</strong>, EFM32, EFR, logo and combinations thereof, and others are the registered trademarks ortrademarks of <strong>Energy</strong> <strong>Micro</strong> AS. ARM, CORTEX, THUMB are the registered trademarks of ARM Limited.Other terms and product names may be trademarks of others.2013-05-08 - an0017_Rev1.07 8 www.energymicro.com


B Contact Information...the world's most energy friendly microcontrollersB.1 <strong>Energy</strong> <strong>Micro</strong> Corporate HeadquartersPostal Address Visitor Address Technical Support<strong>Energy</strong> <strong>Micro</strong> ASP.O. Box 4633 NydalenN-0405 OsloNORWAYwww.energymicro.comPhone: +47 23 00 98 00Fax: + 47 23 00 98 01B.2 Global Contacts<strong>Energy</strong> <strong>Micro</strong> ASSandakerveien 118N-0484 OsloNORWAYsupport.energymicro.comPhone: +47 40 10 03 01Visit www.energymicro.com for information on global distributors and representatives or contactsales@energymicro.com for additional information.Americas Europe, Middle East and Africa Asia and Pacificwww.energymicro.com/americas www.energymicro.com/emea www.energymicro.com/asia2013-05-08 - an0017_Rev1.07 9 www.energymicro.com


...the world's most energy friendly microcontrollersTable of Contents1. LE<strong>UART</strong> Theory ....................................................................................................................................... 21.1. General theory ............................................................................................................................... 22. LE<strong>UART</strong> Configuration ............................................................................................................................... 32.1. Frames, Transmission & Parity .......................................................................................................... 32.2. Clock Sources ................................................................................................................................ 32.3. Baud rates .................................................................................................................................... 32.4. DMA Integration ............................................................................................................................. 42.5. Pulse Generator and Extender .......................................................................................................... 42.6. Interrupts ....................................................................................................................................... 42.7. Freeze Mode and LF Domain Synchronisation ..................................................................................... 42.8. Half-Duplex Operation ..................................................................................................................... 52.9. GPIO and Routing .......................................................................................................................... 53. Software Examples .................................................................................................................................... 63.1. Listening and Receiving in EM2. ........................................................................................................ 63.2. Transmitting in EM2. ....................................................................................................................... 64. Revision History ........................................................................................................................................ 74.1. Revision 1.07 ................................................................................................................................. 74.2. Revision 1.06 ................................................................................................................................. 74.3. Revision 1.05 ................................................................................................................................. 74.4. Revision 1.04 ................................................................................................................................. 74.5. Revision 1.03 ................................................................................................................................. 74.6. Revision 1.02 ................................................................................................................................. 74.7. Revision 1.01 ................................................................................................................................. 74.8. Revision 1.00 ................................................................................................................................. 7A. Disclaimer and Trademarks ........................................................................................................................ 8A.1. Disclaimer ..................................................................................................................................... 8A.2. Trademark Information .................................................................................................................... 8B. Contact Information ................................................................................................................................... 9B.1. <strong>Energy</strong> <strong>Micro</strong> Corporate Headquarters ................................................................................................ 9B.2. Global Contacts ............................................................................................................................. 92013-05-08 - an0017_Rev1.07 10 www.energymicro.com


...the world's most energy friendly microcontrollersList of Figures1.1. LE<strong>UART</strong> two link full duplex connection ...................................................................................................... 22.1. LE<strong>UART</strong> frame format ............................................................................................................................. 32013-05-08 - an0017_Rev1.07 11 www.energymicro.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!