AVR4013: picopower Basics. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

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

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

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

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

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

General Porting Considerations. Memory EEPROM XRAM

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

USER GUIDE EDBG. Description

AT91SAM ARM-based Flash MCU. Application Note

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

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

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

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

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

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

8051 Flash Microcontroller. Application Note. A Digital Thermometer Using the Atmel AT89LP2052 Microcontroller

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

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

How To Design An Ism Band Antenna For 915Mhz/2.4Ghz Ism Bands On A Pbbb (Bcm) Board

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

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

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

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

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

Atmel AVR4027: Tips and Tricks to Optimize Your C Code for 8-bit AVR Microcontrollers. 8-bit Atmel Microcontrollers. Application Note.

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

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

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

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

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

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

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

AVR2006: Design and characterization of the Radio Controller Board's 2.4GHz PCB Antenna. Application Note. Features.

APPLICATION NOTE. Atmel AVR600: STK600 Expansion, Routing and Socket Boards. Atmel Microcontrollers. Introduction

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

AVR1324: XMEGA ADC Selection Guide. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

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

8-bit Microcontroller. Application Note. AVR400: Low Cost A/D Converter

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

Introducing a platform to facilitate reliable and highly productive embedded developments

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

APPLICATION NOTE. AT03155: Real-Time-Clock Calibration and Compensation. SAM3 / SAM4 Series. Scope

Software Real Time Clock Implementation on MC9S08LG32

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

AT88CK490 Evaluation Kit

Atmel Norway XMEGA Introduction

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary. Features. Applications. 1. Description

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

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

AVR030: Getting Started with IAR Embedded Workbench for Atmel AVR. 8-bit Microcontrollers. Application Note. Features.

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

CryptoAuth Xplained Pro

8-bit RISC Microcontroller. Application Note. AVR182: Zero Cross Detector

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

AVR2004: LC-Balun for AT86RF230. Application Note. Features. 1 Introduction

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

1Mb (64K x 16) One-time Programmable Read-only Memory

AN3332 Application note

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

APPLICATION NOTE. Atmel AVR2033: SAM-ICE Adapter Hardware User Manual. 8-bit Atmel Microcontrollers. Features. Introduction

AVR245: Code Lock with 4x4 Keypad and I2C LCD. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note. C51 Bootloaders. C51 General Information about Bootloader and In System Programming. Overview. Abreviations

8-bit RISC Microcontroller. Application Note. AVR910: In-System Programming

AN2680 Application note

AN3265 Application note

QT1 Xplained Pro. Preface. Atmel QTouch USER GUIDE

USER GUIDE. ZigBit USB Stick User Guide. Introduction

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

Software Prerequisites Linux Ubuntu LTS. Estimated completion time: 15min. The goal of this hands-on is to:

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

APPLICATION NOTE. Atmel AT01180: Barcode and QR code scanner User Guide. Atmel 32-bit Microcontroller. Features. Introduction

Application Note. 1. Introduction. 2. Associated Documentation. 3. Gigabit Ethernet Implementation on SAMA5D3 Series. AT91SAM ARM-based Embedded MPU

AN4646 Application note

AN2604 Application note

AN3252 Application note

AVR32110: Using the AVR32 Timer/Counter. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

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

8-bit Microcontroller. Application Note. AVR105: Power Efficient High Endurance Parameter Storage in Flash Memory

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

8-bit RISC Microcontroller. Application Note. AVR155: Accessing an I 2 C LCD Display using the AVR 2-wire Serial Interface

AT91 ARM Thumb Microcontrollers. AT91SAM CAN Bootloader. AT91SAM CAN Bootloader User Notes. 1. Description. 2. Key Features

Tire pressure monitoring

Atmel AVR4950: ASF - USB Host Stack. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

Transcription:

AVR4013: picopower Basics Features Sleep modes PRR registers Oscillator calibration USART 1 Introduction In this demonstration we will show you how to extend the battery life of our application by multiple factors by modifying only the firmware. You will see that while some of the modifications are very simple and only require setting some registers, other modifications will need some rewriting of the code. We will use a capacitor as a battery in this demonstration because it is easy to recharge with the same amount of energy. We will use the discharge time as a measure of power consumption. Our demonstration application will do one ADC measurement, perform 1000 cycles worth of processing, and send the string More oomph to your amps, picopower! and the iterations count on the UART. This will be repeated each second. Before reading this application note, you should download the datasheet for the ATmega88PA from http://www.atmel.com/dyn/resources/prod_documents/doc8271.pdf 8-bit Microcontrollers Application Note Figure 1-1. Demonstration application Rev.

2 Schematics DC C1 VCC TOSC1 TOSC2 ATMega88PA 9 10 32kHz GND TX 3 UART R1 0010010101110. Figure 2-1. picopower demonstration schematics From Figure 2-1 we can see that the demonstration circuit is quite simple. We have a DC source set at 5.5V, which is used to charge the capacitor when the switch is pushed. When the switch is released, the ATmega88PA will run off the energy stored in the capacitor, C1. The main clock source for the device is the internal RC oscillator. Timer 2 is connected to an external crystal and will work in asynchronous mode to be able to function in some of the sleep modes which we will make use of in the demonstration. 3 The code The code is meant to simulate a sensor device that transmits data once a second. After the initialization (which will differ with each optimization method), the code will enter an infinite loop. This loop is separated into stages: ADC conversion Simulated 1000 cycles of processing Convert number in to ASCII string Send data over UART (More oomph to your amps, picopower! [iteration nr]) Repeat The loop will start by doing one ADC conversion to simulate data gathering from some analog device. Then the device will enter a function that simulates 1000 cycles of data processing. In many applications, converting a number to its ASCII representation is preferred, and so we convert the iteration count of the loop to ASCII. Finally, we send the string More oomph to your amps, picopower! [iteration count] over the UART. Then the loop repeats. 2 AVR4013

4 Source code availability 5 Demonstration stages AVR4013 The code for all five optimization levels is included in a separate.zip file, and has been tested with AVR Studio 4.18 RC2 and the WinAVR-20100110 toolchain. The code consists of five levels of optimization, each level offering increased power saving in the application. No optimization Enable pull-ups on unused I/O pins and disable modules not used Pre-scale clock from 8Mhz to 2MHz Use power-save sleep mode while waiting for next transmit Calibrate oscillator to enable higher baud rate Before we start the demonstration we must calibrate the internal RC oscillator. This is to make sure that the baud rate generator is able to generate a stable clock source over the entire voltage range. Oscillator calibration is highly device depended, and referring to the ATmega88PA datasheet, the factory calibration of the internal RC oscillator has an accuracy of ±10% (see section 28.4.1, Calibrated Internal RC Oscillator Accuracy, in the datasheet) and user calibration accuracy is within ±1%. To do this, you can use an oscilloscope and enable the CKOUT fuse (see section 27.2, Fuse Bits, in the datasheet) to find the frequency closest to 8MHz. You will use the OSCCAL register to calibrate the oscillator (see OSCCAL Oscillator Calibration Register in the datasheet), and refer to application note AVR053 for a good way to calibrate the oscillator. On the ATmega88PA used in this example, we found that the value 0x66 in the OSCCAL register gave the best frequency. 5.1 No optimization We start by running the code with no optimization to create a reference point. We execute the code with the device set at 8MHz and the baud rate generator set to 19200 baud. While waiting for the next transmit, the controller will poll the TIFR2 Timer/Counter 2 Interrupt Flag Register to check if a second has elapsed since the last transmit started. This approach will run the code in active mode all the time Runtime: 6 seconds. 3

5.2 Enable pull-ups on unused I/O pins and disable modules not used To remove some power consumption, we will enable pull-ups on unused I/O pins to get a defined logical level and avoid unnecessary switching. To enable pull-ups on the I/O pins, we set the pins to input in the Port Data Direction Register and set the Port Data Register to high level (see section 13.2.1, Configuring the Pin, in the datasheet). Code: DDRA = 0x00; // Set direction to input on all pins PORTA = 0xFF; // Enable pull-ups on pins Another power-saving feature is to disable unused on-chip modules in the PRR Power Reduction Register (see section 9.10, Minimizing Power Consumption, in the datasheet). We are not using the TWI, Timer/Counter 0, Timer/Counter 1, and Serial Peripheral Interface modules, and will therefore disable these modules. Code: void enable_prr() { } power_spi_disable(); power_timer0_disable(); power_timer1_disable(); power_twi_disable(); Runtime is increased to 9 seconds. 5.3 Pre-scale clock from 8MHz to 2MHz Because we have been using the device at 8MHz, we have to configure the BOD (brown out detection) level at 2.7V. The ATmega88PA is not rated to run at lower voltages with the clock set at 8MHz (see section 28.3, Speed Grades, in the datasheet). Therefore, we will halt the execution at 2.7V, which means that a lot of energy will be left in the capacitor which we will not be able to utilize with this setting. We do not need the processing capacity of a device running at 8Mhz, and should instead decrease the system frequency to 2MHz, which will lower overall power consumption and allow us to change the BOD setting to 1.8V. We will still be able to generate a stable baud rate of 19200. To pre-scale the RC oscillator output with 4 to get 2MHz (8MHz / 4 = 2MHz) we use the CLKPR Clock Prescale Register. The AVR toolchain includes a macro for this that is found in the power.h header file. Code: clock_prescale_set(clock_div_4); // This divides the clock by 4 4 AVR4013 Runtime is now increased to 40 seconds.

5.4 Use power-save sleep mode while waiting for next transmit AVR4013 As the ATmega88PA is not processing any data while waiting for its next UART data transmission, it s a good idea to put the device into sleep mode to further reduce power consumption In the power-save sleep mode (see section 9.1, Sleep Modes, in the datasheet) we can use Timer 2 as our wakeup source. Brown out detection is not required in the power-save sleep mode because no data can be corrupted. It will be automatically re-enabled on wakeup from sleep (see section 9.2, BOD Disable, in the datasheet), so we choose to disable the BOD while sleeping The AVR toolchain includes a header file, sleep.h, which has functions for setting sleep mode, disabling BOD, and putting the device into sleep. These functions are called: set_sleep_mode() selects which sleep mode to use when the sleep instruction is executed sleep_enable() enables sleep modes sleep_bod_disable() disables BOD while sleeping sleep_cpu() executes the sleep instruction Runtime is now 198 seconds. 5.5 Calibrate oscillator to enable higher baud rate Another approach to reduce power consumption is to reduce the time spent in active mode. In this application, the CPU is active while waiting for the UART transmission to end. We will calibrate the oscillator to a frequency that allows a higher baud rate on the UART to reduce the time spent in active mode. We need a frequency close to 7.3728MHz to generate a stable baud rate of 115.2kbps (see section 19.10, Examples of Baud Rate Setting, in the datasheet). You will need to set the frequency a bit higher than 7.3728MHz to be able to utilize the whole voltage range. You will also want to divide the clock by 4 to get 1.8432MHz to still be able to run the device with the 1.8V BOD setting. We change the OSCCAL value to 0x5e. Runtime is now increased to 217 seconds. 5.6 Conclusion By structuring your application and understanding the power saving techniques mentioned in this document, you can reduce energy consumption without doing any changes to your PCB. In this example, the runtime was increased from 6 to 217 seconds running off the same power source. 5

6 References [1]: ATmega88PA datasheet: http://www.atmel.com/dyn/resources/prod_documents/8271s.pdf [2]: Application note AVR053: http://www.atmel.com/dyn/resources/prod_documents/doc2555.pdf 6 AVR4013

Disclaimer Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 USA Tel: (+1)(408) 441-0311 Fax: (+1)(408) 487-2600 www.atmel.com Atmel Asia Limited Unit 01-5 & 16, 19F BEA Tower, Milennium City 5 418 Kwun Tong Road Kwun Tong, Kowloon HONG KONG Tel: (+852) 2245-6100 Fax: (+852) 2722-1369 Atmel Munich GmbH Business Campus Parkring 4 D-85748 Garching b. Munich GERMANY Tel: (+49) 89-31970-0 Fax: (+49) 89-3194621 Atmel Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chou-ku, Tokyo 104-0033 JAPAN Tel: (+81) 3523-3551 Fax: (+81) 3523-7581 2010 Atmel Corporation. All rights reserved. / Rev.: CORP072610 Atmel, logo and combinations thereof, and others are registered trademarks of Atmel Corporation or its subsidiaries. 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 product 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.