AVR42783: Using USART to Wake Up ATmega328PB from Sleep Mode. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

Similar documents
AT15007: Differences between ATmega328/P and ATmega328PB. Introduction. Features. Atmel AVR 8-bit Microcontrollers APPLICATION NOTE

APPLICATION NOTE. Atmel AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Atmel AVR 8-bit Microcontroller. Introduction.

AT88CK490 Evaluation Kit

APPLICATION NOTE. Secure Personalization with Transport Key Authentication. ATSHA204A, ATECC108A, and ATECC508A. Introduction.

SMARTCARD XPRO. Preface. SMART ARM-based Microcontrollers USER GUIDE

USER GUIDE EDBG. Description

CryptoAuth Xplained Pro

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

AVR106: C Functions for Reading and Writing to Flash Memory. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

AVR131: Using the AVR s High-speed PWM. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

AVR1321: Using the Atmel AVR XMEGA 32-bit Real Time Counter and Battery Backup System. 8-bit Microcontrollers. Application Note.

APPLICATION NOTE. Authentication Counting. Atmel CryptoAuthentication. Features. Introduction

APPLICATION NOTE. AT16268: JD Smart Cloud Based Smart Plug Getting. Started Guide ATSAMW25. Introduction. Features

General Porting Considerations. Memory EEPROM XRAM

APPLICATION NOTE. AT07175: SAM-BA Bootloader for SAM D21. Atmel SAM D21. Introduction. Features

APPLICATION NOTE Atmel AT02509: In House Unit with Bluetooth Low Energy Module Hardware User Guide 8-bit Atmel Microcontroller Features Description

Atmel AVR4903: ASF - USB Device HID Mouse Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

How To Use An Atmel Atmel Avr32848 Demo For Android (32Bit) With A Microcontroller (32B) And An Android Accessory (32D) On A Microcontroller (32Gb) On An Android Phone Or

AVR115: Data Logging with Atmel File System on ATmega32U4. Microcontrollers. Application Note. 1 Introduction. Atmel

Application Note. 8-bit Microcontrollers. AVR270: USB Mouse Demonstration

AVR1510: Xplain training - XMEGA USART. 8-bit Microcontrollers. Application Note. Prerequisites. 1 Introduction

AVR315: Using the TWI Module as I2C Master. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

Atmel AVR4921: ASF - USB Device Stack Differences between ASF V1 and V2. 8-bit Atmel Microcontrollers. Application Note. Features.

APPLICATION NOTE. AT12405: Low Power Sensor Design with PTC. Atmel MCU Integrated Touch. Introduction

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. Atmel Microcontrollers. Application Note. Features.

AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR32701: AVR32AP7 USB Performance. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR311: Using the TWI Module as I2C Slave. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

USER GUIDE. ZigBit USB Stick User Guide. Introduction

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

APPLICATION NOTE. Atmel AT04389: Connecting SAMD20E to the AT86RF233 Transceiver. Atmel SAMD20. Description. Features

8-bit. Application Note. Microcontrollers. AVR282: USB Firmware Upgrade for AT90USB

QT1 Xplained Pro. Preface. Atmel QTouch USER GUIDE

AVR1922: Xplain Board Controller Firmware. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR033: Getting Started with the CodeVisionAVR C Compiler. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR127: Understanding ADC Parameters. Introduction. Features. Atmel 8-bit and 32-bit Microcontrollers APPLICATION NOTE

AVR134: Real Time Clock (RTC) using the Asynchronous Timer. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note. Atmel ATSHA204 Authentication Modes. Prerequisites. Overview. Introduction

32-bit AVR UC3 Microcontrollers. 32-bit AtmelAVR Application Note. AVR32769: How to Compile the standalone AVR32 Software Framework in AVR32 Studio V2

AVR32138: How to optimize the ADC usage on AT32UC3A0/1, AT32UC3A3 and AT32UC3B0/1 series. 32-bit Microcontrollers. Application Note.

AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

AVR1318: Using the XMEGA built-in AES accelerator. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR125: ADC of tinyavr in Single Ended Mode. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1900: Getting started with ATxmega128A1 on STK bit Microcontrollers. Application Note. 1 Introduction

AVR353: Voltage Reference Calibration and Voltage ADC Usage. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1600: Using the XMEGA Quadrature Decoder. 8-bit Microcontrollers. Application Note. Features. 1 Introduction. Sensors

Application Note. 8-bit Microcontrollers. AVR272: USB CDC Demonstration UART to USB Bridge

AT11805: Capacitive Touch Long Slider Design with PTC. Introduction. Features. Touch Solutions APPLICATION NOTE

AVR126: ADC of megaavr in Single Ended Mode. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

AVR287: USB Host HID and Mass Storage Demonstration. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Using CryptoMemory in Full I 2 C Compliant Mode. Using CryptoMemory in Full I 2 C Compliant Mode AT88SC0104CA AT88SC0204CA AT88SC0404CA AT88SC0808CA

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

APPLICATION NOTE. Atmel AVR443: Sensor-based Control of Three Phase Brushless DC Motor. Atmel AVR 8-bit Microcontrollers. Features.

AVR1301: Using the XMEGA DAC. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

APPLICATION NOTE. AT05558: Wireless Manufacturing Test Kit. Atmel ATmega256RFR2. Description. Features

Atmel SMART ARM Core-based Embedded Microprocessors

AT91SAM ARM-based Flash MCU. Application Note

APPLICATION NOTE. Atmel AT02985: User s Guide for USB-CAN Demo on SAM4E-EK. Atmel AVR 32-bit Microcontroller. Features. Description.

Atmel Power Line Communications. Solutions for the Smart Grid

APPLICATION NOTE. RF System Architecture Considerations ATAN0014. Description

AVR32788: AVR 32 How to use the SSC in I2S mode. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

APPLICATION NOTE. Atmel LF-RFID Kits Overview. Atmel LF-RFID Kit. LF-RFID Kit Introduction

Application Note. Atmel CryptoAuthentication Product Uses. Atmel ATSHA204. Abstract. Overview

Dell One Identity Cloud Access Manager How to Configure vworkspace Integration

Using the RS232 serial evaluation boards on a USB port

Dell Spotlight on Active Directory Server Health Wizard Configuration Guide

AN3332 Application note

Spotlight Management Pack for SCOM

APPLICATION NOTE. Atmel AT01095: Joystick Game Controller Reference Design. 8-/16-bit Atmel Microcontrollers. Features.

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

Dell InTrust Preparing for Auditing Cisco PIX Firewall

Atmel AVR1017: XMEGA - USB Hardware Design Recommendations. 8-bit Atmel Microcontrollers. Application Note. Features.

Dell Statistica. Statistica Document Management System (SDMS) Requirements

AN3265 Application note

MODFLEX MINI GATEWAY ETHERNET USER S GUIDE

APPLICATION NOTE. AT17284: Proximetry Cloud Based Smart Plug User Guide. SMART ARM-based Microcontrollers. Introduction. Features

Designing Feature-Rich User Interfaces for Home and Industrial Controllers

AN974 APPLICATION NOTE

Software Real Time Clock Implementation on MC9S08LG32

AVR055: Using a 32kHz XTAL for run-time calibration of the internal RC. 8-bit Microcontrollers. Application Note. Features.

AT09333: USB Host Interface (UHI) for Communication Class Device (CDC) Introduction. Atmel Microcontrollers APPLICATION NOTE

SAMA5D2. Scope. Reference Documents. Atmel SMART ARM-based MPU ERRATA

Atmel Norway XMEGA Introduction

AN3354 Application note

Two mechanical buttons Two user LEDs Four expansion headers. Board controller with USB interface. One power LED and one status LED

Dell One Identity Cloud Access Manager How to Configure for SSO to SAP NetWeaver using SAML 2.0

8-bit Microcontroller. Application Note. AVR415: RC5 IR Remote Control Transmitter. Features. Introduction. Figure 1.

Dell Migration Manager for Enterprise Social What Can and Cannot Be Migrated

Introducing a platform to facilitate reliable and highly productive embedded developments

USER GUIDE. ATWINC1500B Hardware Design Guidelines - IEEE b/g/n IoT Module. Atmel SmartConnect. Introduction

Application Note. 8-bit Microcontrollers. AVR293: USB Composite Device

4.0. Offline Folder Wizard. User Guide

Atmel AT32UC3A3256 microcontroller 64MBit SDRAM Analog input (to ADC) Temperature sensor RC filter

Dell One Identity Cloud Access Manager How To Deploy Cloud Access Manager in a Virtual Private Cloud

AVR1003: Using the XMEGA Clock System. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

New Features and Enhancements

Atmel AVR ATxmega384C3 microcontroller OLED display with pixels resolution Analog sensors. Ambient light sensor Temperature sensor

AN4646 Application note

Temperature & Humidity SMS Alert Controller

Transcription:

AVR 8-bit Microcontrollers AVR42783: Using USART to Wake Up ATmega328PB from Sleep Mode APPLICATION NOTE Introduction This application note describes how to wake up ATmega328PB (on the ATmega328PB Xplained Mini kit) from sleep mode by using USART of the Atmel AVR ATmega328PB device. The source code is available for download from Atmel START. An ATmega328PB Xplained Mini kit is used to demonstrate the application. Features Sleep modes USART start frame detection Wake up from sleep mode by using USART

Table of Contents Introduction...1 Features... 1 1. Prerequisties...3 2. ATmega328PB Xplained Mini... 4 2.1. Board Overview...4 2.2. Enumeration and Detection...4 3. Sleep Modes...6 3.1. Overview...6 3.2. Six Sleep Modes...6 3.3. Enter Sleep Mode...6 3.4. Wake Up from Sleep Mode... 7 4. Using USART to Wake Up ATmega328PB from Sleep Mode... 8 4.1. Example...8 4.1.1. USART Configuration... 9 4.1.2. Firmware Flowchart... 9 5. References... 10 6. Revision History... 11 2

1. Prerequisties The solution discussed in this document requires: Atmel Studio 7.0 or later ATmega328PB Xplained Mini kit Example Source Code available in Atmel START 3

2. ATmega328PB Xplained Mini 2.1. Board Overview The ATmega328PB Xplained Mini evaluation kit is a hardware platform to evaluate the Atmel ATmega328PB microcontroller. The evaluation kit comes with a fully integrated debugger that provides seamless integration with Atmel Studio 7.0 (and later). The kit provides access to the features of the ATmega328PB enabling easy integration of the device in a custom design. For more details about this kit, refer to the Atmel ATmega328PB Xplained Mini user guide available at http://www.atmel.com/images/atmel-42469-atmega328pb-xplained-mini_user-guide.pdf. Figure 2-1. ATmega328PB Xplained Mini Kit 2.2. Enumeration and Detection When the ATmega328PB Xplained Mini kit is connected to the PC, Windows will enumerate the device and install the appropriate driver. If the driver installed successfully, medbg will be listed in the Device Manager as medbg Virtual COM port under Ports as shown in the two figures below. Figure 2-2. Tool Enumeration 4

Figure 2-3. Successful medbg Driver Installation 5

3. Sleep Modes 3.1. Overview Sleep modes enable the application to shut down unused modules in the MCU, thereby saving power. The device provides various sleep modes allowing the user to tailor the power consumption to the application requirements. 3.2. Six Sleep Modes The following table shows the different sleep modes, BOD disable ability, and their wake-up sources. Table 3-1. Active Clock Domains and Wake-up Sources in the Different Sleep Modes. Active clock domains Oscillators Wake-up sources Software BOD Timer2 disable Sleep Mode clkcpu clkflash clkio clkadc clkasy clkptc Main clock ssource enabled Timer oscillator enabled INT and PCINT TWI address mmatch SPM/ EEPROM ready ADC WDT USART (4) Other I/O Idle Yes Yes Yes Yes Yes Yes (2) Yes Yes Yes Yes Yes Yes Yes Yes ADC Noise Reduction Yes Yes Yes Yes Yes (2) Yes (3) Yes Yes (2) Yes Yes Yes Yes Power-down Yes (3) Yes Yes Yes Yes Power-save Yes Yes Yes Yes (2) Yes (3) Yes Yes Yes Yes Yes Standby (1) Yes Yes (3) Yes Yes Yes Yes Extended Standby Yes (2) Yes Yes Yes (2) Yes (3) Yes Yes Yes Yes Yes Note: 1. Only recommended with external crystal or resonator selected as clock source. 2. If Timer/Counter2 is running in asynchronous mode. 3. For INT1 and INT0, only level interrupt. 4. Start frame detection, only. For more details about all six sleep modes, refer to the Atmel ATmega328PB datasheet available at http:// www.atmel.com/devices/atmega328pb.aspx. 3.3. Enter Sleep Mode To enter any of the six sleep modes, the Sleep Enable bit in the Sleep Mode Control Register (SMCR.SE) must be written to '1' and a SLEEP instruction must be executed. The table below (SMCR.SM[2:0]) select which sleep mode (Idle, ADC Noise Reduction, Power-down, Power-save, Standby, or Extended Standby) will be activated by the SLEEP instruction. Table 3-2. Sleep Mode Select SM2,SM1,SM0 Sleep Mode 000 Idle 001 ADC Noise Reduction 010 Power-down 011 Power-save 6

SM2,SM1,SM0 Sleep Mode 100 Reserved 101 Reserved 110 Standby 111 Extended Standby 3.4. Wake Up from Sleep Mode If an enabled interrupt occurs while the MCU is in a sleep mode, the MCU wakes up. The MCU is then halted for four cycles in addition to the start-up time, executes the interrupt routine, and resumes execution from the instruction following SLEEP. The contents of the Register File and SRAM are unaltered when the device wakes up from sleep. If a reset occurs during sleep mode, the MCU wakes up and executes from the Reset Vector. 7

4. Using USART to Wake Up ATmega328PB from Sleep Mode The USART start frame detector can wake up the MCU from all six sleep modes when it detects a start bit. When a high-to-low transition is detected on RxDn, the internal 8MHz oscillator is powered up and the USART clock is enabled. After start-up the rest of the data frame can be received, provided that the baud rate is slow enough in relation to the internal 8MHz oscillator start-up time. Start-up time of the internal 8MHz oscillator varies with supply voltage and temperature. The USART start frame detection works both in asynchronous and synchronous modes. It is enabled by writing the Start Frame Detection Enable bit (SFDE). If the USART Start Interrupt Enable (RXSIE) bit is set, the USART Receive Start Interrupt is generated immediately when start is detected. When using the feature without start interrupt, the start detection logic activates the internal 8MHz oscillator and the USART clock while the frame is being received, only. Other clocks remain stopped until the Receive Complete Interrupt wakes up the MCU. The table below describes how to use USART to wake up ATmega328PB from sleep mode. Table 4-1. USART Start Frame Detection Modes SFDE RXSIE RXCIE Description 0 X X Start frame detector disabled 1 0 0 Reserved 1 0 1 Start frame detector enabled. RXC flag wakes up the MCU from all sleep modes. 1 1 0 Start frame detector enabled. RXS flag wakes up the MCU from all sleep modes. 1 1 1 Start frame detector enabled. Both RXC and RXS wake up the MCU from all sleep modes. 4.1. Example The application note provides a code example about how to wake up ATmega328PB from the Powerdown mode (which has the least consumption of all the sleep modes) by using USART. For other sleep modes, just change the argument in the set_sleep_mode() function. The source code is available for download from Atmel START. Here below is the main() function: int main(void) { power_reduction(); uart_init(); sei(); while(1) { if(!ring_buffer_is_empty(&ring_buffer_in)){ usart_transmit( ring_buffer_get(&ring_buffer_in)); } else { set_sleep_mode(sleep_mode_pwr_down); sleep_mode(); } } } 8

4.1.1. USART Configuration This example uses USART0 module. PD0 is used to receive data, and PD1 is used to transmit data. In this example the USART will be configured with the following settings: Asynchronous mode 38400 Baudrate 8-bits, No Parity and one Stop Bit 4.1.2. Firmware Flowchart The figure below shows the firmware flowchart of the example code. Figure 4-1. Flowchart Reset Init Transmit data Yes Are there data to transmit? USART RX complete interrupt routine No Sleep Waiting t he USART start frame detector to wake up the MCU 9

5. References ATmega328PB datasheet (http://www.atmel.com/devices/atmega328pb.aspx) ATmega328PB Xplained Mini kit (http://www.atmel.com/tools/mega328pb-xmini.aspx) Atmel Studio (http://www.atmel.com/tools/atmelstudio.aspx?tab=overview) Atmel START (http://start.atmel.com) 10

6. Revision History Doc Rev. Date Comments 42783A 09/2016 Initial document release 11

Atmel Corporation 1600 Technology Drive, San Jose, CA 95110 USA T: (+1)(408) 441.0311 F: (+1)(408) 436.4200 www.atmel.com 2016 Atmel Corporation. / Rev.: Atmel, Atmel logo and combinations thereof, Enabling Unlimited Possibilities, AVR, and others are registered trademarks or trademarks of Atmel Corporation in U.S. and other countries. Windows is a registered trademark of Microsoft Corporation in U.S. and or other countries. Other terms and product names may be trademarks of others. DISCLAIMER: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life. SAFETY-CRITICAL, MILITARY, AND AUTOMOTIVE APPLICATIONS DISCLAIMER: Atmel products are not designed for and will not be used in connection with any applications where the failure of such products would reasonably be expected to result in significant personal injury or death ( Safety-Critical Applications ) without an Atmel officer's specific written consent. Safety-Critical Applications include, without limitation, life support devices and systems, equipment or systems for the operation of nuclear facilities and weapons systems. Atmel products are not designed nor intended for use in military or aerospace applications or environments unless specifically designated by Atmel as military-grade. Atmel products are not designed nor intended for use in automotive applications unless specifically designated by Atmel as automotive-grade.