APPLICATION NOTE. AT03498: Low Power Modes in SAM3 Family. Atmel AT91 ARM Cortex Microcontrollers. Introduction

Similar documents
APPLICATION NOTE. Atmel AT03782: Using Low Power Modes in SAM4N Microcontroller. Atmel 32-bit Microcontroller. Features.

APPLICATION NOTE. Atmel AVR1638: XMEGA RTC Calibration. 8-bit Atmel Microcontrollers. Features. Introduction

APPLICATION NOTE. AT03324: Atmel REB212BSMA-EK Quick Start Guide. Atmel MCU Wireless. Introduction

APPLICATION NOTE. Atmel AT01080: XMEGA E Schematic Checklist. Atmel AVR XMEGA E. Features. Introduction

APPLICATION NOTE. Atmel AT03304: SAM D20 I 2 C Slave Bootloader SAM D20. Description. Features

OLED display with pixels resolution Ambient light sensor CPU load Analog filter Quadrature Encoder with push button Digital I/O

AVR1518: XMEGA-A1 Xplained Training - XMEGA Clock System. 8-bit Atmel Microcontrollers. Application Note. Prerequisites.

Hardware Prerequisites Atmel Xplained Pro Evaluation Kit Atmel WINC1500 extension USB Micro Cable (TypeA / MicroB)

Getting Started with the SAM4L-EK Demo

APPLICATION NOTE. Atmel AVR057: Internal RC Oscillator Calibration for ATtiny4/5/9/10/20/40. 8-bit Atmel Microcontrollers. Features.

APPLICATION NOTE. Atmel AT02260: Driving AT42QT1085. Atmel QTouch. Features. Description

APPLICATION NOTE. Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices. Atmel AVR XMEGA. Features.

Atmel AVR32847: Migration from/to the UC3L0 64/32/16 from/to the UC3L0 256/ bit Atmel Microcontrollers. Application Note.

AVR32917: picopower Board getting started. 32-bit Microcontrollers. Application Note. Preliminary. Features. 1 Introduction

STK521. User Guide B AVR 01/12

APPLICATION NOTE. Atmel AVR3009: Driving QTouch Device with I 2 C Interface. Atmel QTouch. Introduction

APPLICATION NOTE. Atmel AVR536: Migration from ATmega644 to ATmega644A. 8-bit Atmel Microcontrollers. Introduction

Atmel AVR1619: XMEGA-B1 Xplained Demonstration. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

USER GUIDE. Wireless Production Test Reference Protocol Specification Document. Atmel MCU Wireless. Description

Atmel QT600 Quick Start Guide Touch Solutions

Atmel ATMXT143E touchscreen controller Capacitive touch ITO 320 x 240 pixel LCD display with SPI interface LED backlight

Section 5 SERCOM. Tasks SPI. In this section you will learn:

OLED display Sensors readout. Light sensor Temperature sensor

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

32Kbytes on-chip SRAM. Viterbi decoding and CRC PRIME compliant 128-bit AES encryption Channel sensing and collision pre-detection

AT11512: SAM L Brown Out Detector (BOD) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

Atmel LF-RFID Kit Comparison Chart. Application Note. Atmel LF-RFID Kit Comparison Chart. 1. Description

APPLICATION NOTE. AT11008: Migration from ATxmega16D4/32D4 Revision E to Revision I. Atmel AVR XMEGA. Introduction. Features

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

Atmel AT697F. Rad-Hard 32-bit SPARC v8 Processor ERRATA SHEET. Active Errata List

USER GUIDE EDBG. Description

Atmel AVR1924: XMEGA-A1 Xplained Hardware User's Guide. 8-bit Atmel Microcontrollers. Application Note. Preliminary. Features.

APPLICATION NOTE. Atmel AVR2131: Lightweight Mesh Getting Started Guide. Atmel MCU Wireless. Features. Description

AVR4018: Inertial Two (ATAVRSBIN2) Hardware User's Guide. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

EDBG. Description. Programmers and Debuggers USER GUIDE

AT91 ARM Thumb-based Microcontroller. Application Note. AT91SAM7X and AT91SAM7XC Microcontroller Series Schematic Check List. 1.

AVR42789: Writing to Flash on the New tinyavr Platform Using Assembly

SAM4 Reset Controller (RSTC)

APPLICATION NOTE. Atmel AVR116: Wear Leveling on DataFlash. 32-bit Atmel Microcontrollers. Features. Description. Wear leveling

Atmel AT697F. Rad-Hard 32-bit SPARC v8 Processor ERRATA SHEET. Active Errata List

Atmel AVR473: ATAVRSB202 Hardware User Guide. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

AVR42772: Data Logger Demo Application on XMEGA A1U Xplained Pro. Introduction. Features. AVR XMEGA Microcontrollers APPLICATION NOTE

AVR097: Migration between ATmega128 and ATmega1281/ATmega bit Microcontrollers. Application Note. Features. 1 Introduction

APPLICATION NOTE. AT04470: Differences between SAM D21 Variants A, B, and L. 32-bit Microcontroller. Introduction

Atmel CryptoAuthentication Starter Kit

AVR532: Migration from ATmega48/88/168 to ATmega48A/88A/168A. 8-bit Microcontrollers. Application Note. 1 Introduction

AVR1503: Xplain training - XMEGA Programmable Multi Interrupt Controller 8-bit Microcontrollers Application Note Prerequisites

AVR1303: Use and configuration of IR communication module. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AT09381: SAM D - Debugging Watchdog Timer Reset. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

AT03975: Getting Started with SAM L21. Descripton. Features. SMART ARM-Based Microcontroller APPLICATION NOTE

8-bit Microcontroller with 16K Bytes In-System Programmable Flash. ATtiny87 ATtiny167 Automotive

AT91 ARM Thumb Microcontrollers. Application Note. AT91M55800A Clock Switching Considerations using Advanced Power Management Controller.

AVR32752: Using the AVR32 UC3 Static Memory Controller. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

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

APPLICATION NOTE. How to Securely Switch Atmel s LIN Transceiver ATA6662/ATA6662C to Sleep Mode ATA6662/ATA6662C. Concerning Atmel ATA6662

AT60142H/HT. Rad-Hard 512Kx8 Very Low Power CMOS SRAM ERRATA-SHEET. Active Errata List. Errata History. Abbreviations. 1.

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

Atmel AVR1926: XMEGA-B1 Xplained Getting Started Guide. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

ATAES132A Firmware Development Library. Introduction. Features. Atmel CryptoAuthentication USER GUIDE

AVR1501: Xplain training XMEGA Timer/Counter 8-bit Microcontrollers Application Note Prerequisites 1 Introduction

SBAT90USB162 Atmel. SBAT90USB162 Development Board User s Manual

a clock signal and a bi-directional data signal (SCL, SDA)

Embedded AVR Microcontroller Including RF Transmitter and Immobilizer LF Functionality for Remote Keyless Entry ATA5795. Summary.

LBAT90USB162 Atmel. LBAT90USB162 Development Board User s Manual

APPLICATION NOTE. AT07216: SAM G55 Schematic Checklist. Atmel SMART SAM G55. Introduction

AT03262: SAM D/R/L/C System Pin Multiplexer (SYSTEM PINMUX) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

AVR1315: Accessing the XMEGA EEPROM. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Ethernet1 Xplained Pro

AT91 ARM Thumb Microcontrollers. Application Note. Migrating to an AT91SAM9G20-based System from an AT91SAM9260-based System. 1. Scope. 2.

USER GUIDE. Atmel QT1 Xplained Pro. Preface

AT06467: Getting started with SAM D09/D10/D11. Features. Description. SMART ARM-based Microcontrollers APPLICATION NOTE

APPLICATION NOTE. Atmel QT4 Xplained Pro User Guide ATAN0114. Preface

One-channel Toggle-mode Touch Sensor IC with Power Management Functions AT42QT1012. Summary

APPLICATION NOTE. Atmel AVR3005: Low Power QTouch Design. Atmel QTouch. Features. Introduction

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

USER GUIDE. Atmel QT6 Xplained Pro. Preface

APPLICATION NOTE. AT06863: SAM4L Peripheral Event Controller (PEVC) SAM4L Peripheral Event Controller (PEVC) ASF PROGRAMMERS MANUAL

AVR1508: Xplain training - XMEGA DAC 8-bit Microcontrollers Application Note Features 1 Introduction

APPLICATION NOTE. AT6486: Using DIVAS on SAMC Microcontroller. SMART ARM-Based Microcontroller. Introduction. Features

APPLICATION NOTE. Atmel AT03261: SAM D20 System Interrupt Driver (SYSTEM INTERRUPT) SAM D20 System Interrupt Driver (SYSTEM INTERRUPT)

Asynchronous SRAM Operating Voltage: 5V Read Access Time: 40 ns Write Cycle Time: 30 ns Very Low Power Consumption (Pre-RAD)

QT3 Xplained Pro. Preface. Atmel QTouch USER GUIDE

SAM4L Asynchronous Timer (AST)

USER GUIDE. Atmel OLED1 Xplained Pro. Preface

AVR based 125kHz RFID Evaluation Kit (Re)Programming Guide ATA2270-EK1. Overview. Fuse Settings: ISP Programming

AVR1512: XMEGA-A1 Xplained training - XMEGA Basics. 8-bit Atmel Microcontrollers. Application Note. Prerequisites. 1 Introduction

Hello, and welcome to this presentation of the STM32L4 power controller. The STM32L4 s power management functions and all power modes will also be

Native route discovery algorithm

AVR32401: AVR32 AP7 Linux Interfacing DataFlash. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AN2202 Application note

QT2 Xplained Pro. Preface. Atmel QTouch USER GUIDE

AT21CS Series Reset and Discovery. Introduction. Serial EEPROM APPLICATION NOTE

SAMA5D2 Quad SPI (QSPI) Performance. Introduction. SMART ARM-based Microprocessor APPLICATION NOTE

CAN Microcontrollers. Application Note. Migrating from T89C51CC01 to AT89C51CC03. Feature Comparison

AT91 ARM Thumb Microcontrollers. Application Note. AT91 Host Flash Loader. 1. Package Contents. 2. Definition of Terms. 3.

8-bit Microcontroller with 2K/4K/8K Bytes In-System Programmable Flash. Appendix A. Preliminary. ATtiny261 ATtiny461 ATtiny861 Automotive

AN4749 Application note

Non Volatile Rad Hard Reprogrammable FPGA. ATF280 SRAM-based FPGA AT69170 Serial EEPROM. 2x SRAM-based FPGA designed for Space use - ATF280

USER GUIDE. Atmel Segment LCD1 Xplained Pro. Preface

USER GUIDE. ATWINC1500 Xplained Pro. Preface

Transcription:

APPLICATION NOTE AT03498: Low Power Modes in SAM3 Family Atmel AT91 ARM Cortex Microcontrollers Introduction The Atmel SAM3 family of microcontrollers is based on the ARM Cortex -M3 CPU architecture. Thanks to Cortex-M3 system sleep mode that can stop the Cortex-M3 and system clocks for greater power reductions, the SAM3 family features various low power modes that can be used to optimize power consumption in applications where low power is a key. This application note is for the Atmel SAM3U/3S/3N series and it is also applicable for other SAM3 series. The purpose of this document is to introduce the part that is used for power supply and various low power modes of SAM3 family, how to enter and exit each low power mode, how to use these low power modes and give suggestions on how to optimize power consumption. This application note also provides a software example to demonstrate how to enter/exit low power modes, and how to measure the power consumption using the Atmel SAM3S-EK board.

Table of Contents 1. Power Supply... 3 1.1 Power Supply of SAM3U... 3 1.2 Power Supply of SAM3S... 4 1.3 Power Supply of SAM3N... 5 1.4 Supply Controller (SUPC)... 6 1.5 Voltage Regulator... 6 1.6 Supply Monitor... 6 1.7 Brown-out Detector (BOD)... 6 1.8 General Purpose Backup Registers (GPBR)... 6 1.9 Power Management Controller (PMC)... 6 1.10 Typical Powering Schematics... 7 2. Various Power Modes... 7 2.1 Active Mode... 7 2.2 Sleep Mode... 7 2.2.1 Enter the Sleep Mode... 8 2.2.2 Exit the Sleep Mode... 8 2.3 Wait Mode... 8 2.3.1 Enter the Wait Mode... 8 2.3.2 Exit the Wait Mode... 10 2.4 Backup Mode... 10 2.4.1 Enter the Backup Mode... 10 2.4.2 Exit the Backup Mode... 10 2.5 Low Power Mode Summary... 11 3. Using Low Power Modes... 12 3.1 Optimizing Power Consumption... 12 3.2 Sleep Mode vs. Polling Loops... 13 3.3 Sleep Mode vs. Wait Mode... 13 3.4 Using Backup Mode... 14 4. Low Power Example... 15 4.1 Hardware Setup... 15 4.2 Running the Example... 15 5. References... 15 6. Revision History... 16 2

1. Power Supply 1.1 Power Supply of SAM3U Figure 1-1 gives an overview of the Supply Controller of the Atmel SAM3U. Figure 1-1. Supply Controller of SAM3U. The SAM3U product has several types of power supply pins: VDDCORE: VDDIO: VDDIN: VDDOUT: VDDBU: VDDPLL: Powers the core, the embedded memories and the peripherals Powers the peripherals I/O lines Powers the voltage regulator It is the output of the voltage regulator; Intended to supply the core of the device Powers the Slow Clock oscillator and a part of Controller Powers the PLL A, UPLL and 3MHz to 20MHz oscillator 3

VDDUTMI: Powers the USB UTMI + interface VDDANA: Powers the ADC cells The device can be divided into two power supply areas: Backup Power Supply and Core Power Supply. 1.2 Power Supply of SAM3S Figure 1-2 gives an overview of the Supply Controller of the Atmel SAM3S. Figure 1-2. Supply Controller of SAM3S. There are several types of power supply pins: VDDCORE: VDDIO: VDDIN: VDDOUT: VDDPLL: Powers the core, the embedded memories and the peripherals Powers the peripherals I/O lines (Input/Output Buffers); USB transceiver; Backup part, 32kHz crystal oscillator and oscillator pads Voltage Regulator Input, ADC, DAC and Analog Comparator Power Supply It is the output of the voltage regulator; Intended to supply the core of the device Powers the PLLA, PLLB, the Fast RC and the 3MHz to 20MHz oscillator The device can be divided into two power supply areas: Backup Power Supply and Core Power Supply. 4

1.3 Power Supply of SAM3N Figure 1-3 gives an overview of the Supply Controller of the Atmel SAM3N. Figure 1-3. Supply Controller of SAM3N. There are several types of power supply pins: VDDCORE: VDDIO: VDDIN: VDDOUT: VDDPLL: Powers the core, the embedded memories and the peripherals Powers the peripherals I/O lines (Input/Output Buffers); USB transceiver; Backup part, 32kHz crystal oscillator and oscillator pads Voltage Regulator Input, ADC, DAC and Analog Comparator Power Supply It is the output of the voltage regulator; Intended to supply the core of the device Powers the PLL, the Fast RC and the 3MHz to 20MHz oscillator The device can be divided into two power supply areas: Backup Power Supply and Core Power Supply. 5

1.4 Supply Controller (SUPC) The Supply Controller controls the supply voltage of the Core of the system and manages the Backup mode by controlling the Embedded Voltage Regulator. The Supply Controller starts up the device by enabling the voltage regulator. Then it generates the proper reset signals to the core power supply. It also enables to set the system in different low power modes and to wake it up from a wide range of events. 1.5 Voltage Regulator The voltage regulator is managed by the Supply Controller. This internal regulator is intended to supply the core of the device but can be used to supply other parts in the application. It features two different operating modes: In Normal mode, the voltage regulator supplies power to core domain, internal adaptive biasing automatically adjusts the regulator quiescent current depending on the required load current. In Wait mode quiescent current is only 7µA In Shutdown mode, the voltage regulator is disabled and its output is driven internally to GND, it consumes less than 1μA. When system enters Backup mode, the SUPC disable voltage regulator automatically In addition, when the user does not use the internal voltage regulator and wants to supply VDDCORE by an external supply, it is possible to disable the voltage regulator. 1.6 Supply Monitor The supply monitor can be used to prevent the processor from falling into an unpredictable state if the Main power supply drops below a certain level. For the Atmel SAM3U series, it monitors VDDUTMI power supply, for SAM3S/3N series, it monitors VDDIO power supply. The threshold of the supply monitor is programmable. It can be selected from 1.9V to 3.4V by steps of 100mV. This threshold is programmed in the SMTH field of the Supply Controller Supply Monitor Mode Register (SUPC_SMMR). To reduce power consumption, Supply Monitor can be disabled by writing the SMSMPL field to 0 in SUPC_SMMR. 1.7 Brown-out Detector (BOD) Brown-out detector monitors on VDDCORE. By default, it is enabled. To reduce power consumption, Brown-out detector can be disabled by writing the BODDIS bit to 1 in SUPC_MR. 1.8 General Purpose Backup Registers (GPBR) The device embeds four 32-bit general-purpose backup registers which can store 16 bytes of user application data. When system enter Backup mode, the voltage regulator is disabled, and VDDCORE is off but the backup registers remain powered by VDDIO (on Atmel SAM3S/3N) or VDDBU (on Atmel SAM3U).They retain the content when the system wakes up from Backup mode. 1.9 Power Management Controller (PMC) The Power Management Controller (PMC) controls all system and peripheral clocks. It acts important role for optimizing power consumption. 6

1.10 Typical Powering Schematics There are three typical powering schematics for the system: Single Supply: The system is powered by single main supply. The internal regulator input connected to the main supply and its output feeds VDDCORE and VDDPLL Core Externally Supplied: The system is power by main supply while the VDDCORE and VDDPLL are powered by core supply Backup Batteries Used: The system is powered by main supply while the backup power supply part is powered by batteries For further information, you can refer to Chapter Power Considerations of relevant device datasheet. 2. Various Power Modes The Atmel SAM3 family of microcontrollers has various power modes, include Active mode and different low power modes (Sleep, Wait and Backup). Various power modes are shown in Figure 2-1. Each low power mode can be entered from Active mode and wake up by related enabled wake-up event. The various low power modes are described below. Figure 2-1. SAM3 Various Power Modes. 2.1 Active Mode Active mode is the normal running mode. By default, the microcontroller is in Active mode after power on. Following means can reduce power consumption in Active mode: Slow down the system clock Disable the peripheral clocks when they are unused The power management controller (PMC) can be used to adapt the frequency and to disable the peripheral clocks. 2.2 Sleep Mode In Sleep mode, the execution of instructions is suspended because the core clock is stopped while the peripheral clocks can be enabled. The purpose of sleep mode is to optimize power consumption of the device versus response time. The core needs lowest wakeup time in this mode. 7

2.2.1 Enter the Sleep Mode Sleep mode is entered via Wait for Interrupt (WFI) or Wait for Event (WFE) instructions with LPM = 0 in PMC_FSMR. This mode is achieved by disabling the core clock by PMC. Following code snippet shows how to enter Sleep mode: /** * \brief Enter Sleep Mode. * Enter condition: (WFE or WFI) + (SLEEPDEEP bit = 0) + (LPM bit = 0) * * \param type 0 - wait for interrupt, 1 - wait for event. */ void EnterSleepMode(uint8_t type) { PMC->PMC_FSMR &= (uint32_t)~pmc_fsmr_lpm; SCB->SCR &= (uint32_t)~scr_sleepdeep; if (type == 0) { WFI(); } else { WFE(); } } When Sleep mode is entered, the current instruction is finished before the clock is stopped, but this does not prevent data transfers from other masters of the system bus. 2.2.2 Exit the Sleep Mode Sleep mode is exited from an interrupt if WFI instruction of the Cortex-M3 is used, or from an event if the WFE instruction is used to enter this mode, or by the reset of the device. The PMC automatically re-enables the processor clock (PCK) and the core executes the next instruction of the program counter. 2.3 Wait Mode The purpose of the wait mode is to achieve very low power consumption while maintaining the whole device in a powered state for a startup time of less than 10μs. In this mode, the clocks of the core, peripherals and memories are stopped. However, the core, peripherals and memories power supplies are still powered. 2.3.1 Enter the Wait Mode Wait mode is entered via Wait for Event (WFE) instructions with LPM = 1 (Low Power Mode bit in PMC_FSMR). The Fast RC Oscillator is disabled by the PMC automatically when entering Wait mode. The step of entering Wait mode as below: Select the 4/8/12 MHz Fast RC Oscillator as Main Clock Set the LPM bit in the PMC Fast Startup Mode Register (PMC_FSMR) Execute the Wait-For-Event (WFE) instruction of the processor Note: Internal Main clock resynchronization cycles are necessary between the writing of MOSCRCEN bit and the effective entry in Wait mode. Depending on the user application, waiting for MOSCRCEN bit to be cleared is recommended to ensure that the core will not execute undesired instructions. In most application, the external XTAL oscillator is used instead of on-chip RC oscillator for accurate clock. Following code snippet shows how to switch MCK from external XTAL oscillator to Fast RC oscillator: /** * \brief Switch MCK to FastRC (Main On-Chip RC Oscillator). * * \param moscrcf Main On-Chip RC Oscillator Frequency Selection. * \param pres Processor Clock Prescaler. */ 8

void SwitchMck2FastRC(uint32_t moscrcf, uint32_t pres) { /* Enable Fast RC oscillator but DO NOT switch to RC now. Keep MOSCSEL to 1 */ PMC->CKGR_MOR = CKGR_MOR_MOSCSEL (0x37 << 16) CKGR_MOR_MOSCXTEN CKGR_MOR_MOSCRCEN; /* Wait the Fast RC to stabilize */ while (!(PMC->PMC_SR & PMC_SR_MOSCRCS)); /* Switch from Main Xtal osc to Fast RC */ PMC->CKGR_MOR = (0x37 << 16) CKGR_MOR_MOSCRCEN CKGR_MOR_MOSCXTEN ; /* Wait for Main Oscillator Selection Status bit MOSCSELS */ while (!(PMC->PMC_SR & PMC_SR_MOSCSELS)); /* Disable Main XTAL Oscillator */ PMC->CKGR_MOR = (0x37 << 16) CKGR_MOR_MOSCRCEN; /* Change frequency of Fast RC oscillator */ PMC->CKGR_MOR = (0x37 << 16) PMC->CKGR_MOR moscrcf; /* Wait the Fast RC to stabilize */ while (!(PMC->PMC_SR & PMC_SR_MOSCRCS)); /* Switch to main clock */ PMC->PMC_MCKR = (PMC->PMC_MCKR & (uint32_t)~pmc_mckr_css) PMC_MCKR_CSS_MAIN_CLK; while (!(PMC->PMC_SR & PMC_SR_MCKRDY)); PMC->PMC_MCKR = (PMC->PMC_MCKR & (uint32_t)~pmc_mckr_pres) pres; while (!(PMC->PMC_SR & PMC_SR_MCKRDY)); /* Stop PLL A */ /* STMODE must be set at 2 when the PLLA is Off */ PMC->CKGR_PLLAR = 0x2 << 14; } /* Stop PLLB */ /* STMODE must be set at 2 when the PLLB is OFF */ PMC->CKGR_PLLBR = 0x2 << 14; Following code snippet shows how to enter Wait mode: /** * \brief Enter Wait Mode. * Enter condition: WFE + (SLEEPDEEP bit = 0) + (LPM bit = 1) */ void EnterWaitMode(void) { uint32_t i; PMC->PMC_FSMR = PMC_FSMR_LPM; SCB->SCR &= (uint32_t)~scr_sleepdeep; WFE(); } /* Waiting for MOSCRCEN bit is cleared is strongly recommended * to ensure that the core will not execute undesired instructions */ for (i = 0; i < 500; i++) { NOP(); } while (!(PMC->CKGR_MOR & CKGR_MOR_MOSCRCEN)); 9

2.3.2 Exit the Wait Mode Wait mode can be exited from several asynchronous fast start-up sources that have to be programmed prior to entering this mode, include: WKUP0-15 pins RTT or RTC alarm USB Wake-up As soon as the fast start-up signal is asserted, the PMC automatically restarts the embedded 4/8/12 MHz fast RC oscillator, switches the master clock on this 4/8/12 MHz clock and re-enables the processor clock and then the core executes the next instruction of the program counter. 2.4 Backup Mode The purpose of backup mode is to achieve the lowest power consumption in a system but not requiring fast startup time (<0.5ms). Backup mode is based on the Cortex-M3 deep-sleep mode with the voltage regulator disabled (no power supply for VDDCORE and VDDPLL). The core power supply domain is powered off and the SRAM, flash memory, PLL and peripherals are also switched off. The backup power supply domain is still powered so the Supply Controller, zeropower power-on reset, RTT, RTC, Backup registers and 32kHz oscillator are running. 2.4.1 Enter the Backup Mode Backup mode is entered by using WFE instructions with the SLEEPDEEP bit in the System Control Register of the Cortex-M3 set to 1. The regulator and the core supply are off. Following code snippet shows how to enter Backup mode: 2.4.2 Exit the Backup Mode /** * \brief Enter Backup Mode. * Enter condition: WFE + (SLEEPDEEP bit = 1) */ void EnterBackupMode(void) { SCB->SCR = SCR_SLEEPDEEP; WFE(); } Backup mode can be exited from several wake-up sources that must first be programmed prior to entering this mode, includes: WKUPEN0-15 pins (level transition, configurable debouncing) RTC alarm RTT alarm Supply Monitor alarm (on Atmel SAM3S series) BOD alarm (on Atmel SAM3U series) FWUP pin (on SAM3U series) When waking up from Backup mode, the program execution restarts in the same way as system startup except backup region (RTC, RTT, GPBR and Supply Controller) are not reset. 10

2.5 Low Power Mode Summary Table 2-1 shows a summary of the configurations of the low power modes. Table 2-1. Low Power Mode Configuration Summary. Mode Backup mode Wait mode Sleep mode SUPC, 32kHz oscillator RTC RTT backup registers, POR (backup region) ON ON ON Voltage regulator OFF SHDN =0 ON SHDN =1 ON SHDN =1 Core memory peripherals Mode entry Potential wake up sources Core at wake up OFF WFE FWUP pin (on SAM3U) (Not powered) +SLEEPDEEP bit = 1 SM alarm (on SAM3S) WUP0-15 pins BOD alarm RTC alarm RTT alarm Powered (Not clocked) Powered (Not clocked) WFE Any Event from: Fast startup +SLEEPDEEP bit = 0 through WUP0-15 pins +LPM bit = 1 RTC alarm RTT alarm USB wake-up WFE or WFI Entry mode =WFI Interrupt Only; +SLEEPDEEP bit = 0 Entry mode =WFE Any Enabled +LPM bit = 0 Interrupt and/or Any Event from: Fast start-up through WUP0-15 pins RTC alarm RTT alarm USB wake-up Reset Clocked back Clocked back 11

3. Using Low Power Modes 3.1 Optimizing Power Consumption Normally, the system power consumption increases with the clock frequency. There is a trade-off between power consumption and system performance. The Atmel SAM3 family of microcontrollers embeds a Power Management Controller (PMC) for optimizing power consumption by controlling all system and user peripheral clocks. Figure 3-1. General Clock Block Diagram of SAM3S. Normally, the system needs not to run at maximum frequency. According to system performance requirement, proper Master Clock (MCK) needs to be found for optimizing power consumption. The user can choose one of the following clocks as master clock source by writing the relevant value in the CSS field of the PMC_MCKR register: Slow clock Main clock PLLA clock PLLB clock on Atmel SAM3S / UPLLCK on Atmel SAM3U 12

And the Master Clock (MCK) can be divided in the range of 1 to 64 by writing the relevant value in the PRES field of the PMC_MCKR register. The peripheral clocks are automatically disabled after a reset. The user can individually enable and disable the Master Clock on the peripherals by writing into the Peripheral Clock Enable (PMC_PCER) and Peripheral Clock Disable (PMC_PCDR) registers. In order to reduce power consumption, it is recommended to disable the clock of unused peripherals. If PLL clock is not used, it is recommended to disable it for power saving. The Brownout Detector monitors VDDCORE. It is enabled by default. It is especially recommended to disable it during low power modes for saving power consumption. It can be deactivated by software through the Supply Controller (SUPC_MR). When the core is not required for executing instruction, the low power modes can be used to further reduce power consumption. Following sections have more discussion on this. 3.2 Sleep Mode vs. Polling Loops In most applications, there are some polling loops for waiting for operation finish. For example, you need to send a large amount of data via USART; the pseudo code might like this: SendDataViaUSART() { Begin to send data via USART by PDC; Wait for transfer finish; Continue to execute next operation; } There are two ways for waiting for transfer finish: Polling loops, like while(transfer not finish) {1} Enter sleep mode and set the core be woken up by an interrupt when transfer finish. By using polling loops, the instructions are still executed thereby increasing power consumption. By using Sleep mode, the core clock is stopped thereby reducing power consumption while USART peripheral clock is still working, so data transfer continue. When the transfer finish, an interrupt will wake up the core immediately. So in the case of the core is not running while waiting for peripherals transfer data done (with DMA or PDC), it is recommended to use the Sleep mode instead of polling loops. 3.3 Sleep Mode vs. Wait Mode Some applications are not running all the time. For example, an alarm application waits for signal from a sensor to wake up the microcontroller to launch a task. In this case, the microcontroller can be suspended during idle time and woken up in time when specific event happens. Both Sleep mode and Wait mode may be used for reducing power consumption. Some main factors should be considered: wakeup source power consumption wakeup time If the wakeup source is an interrupt in the application, only Sleep mode can be used because Wait mode can only be woken up by programmed events. Refer Table 2-1 for the different wakeup sources for Sleep mode and Wait mode. 13

For power consumption, in Wait mode, current consumption is typically 15µA when the internal voltage regulator is used. In Sleep mode, current consumption depends on master clock and peripherals in used. The current consumption in Sleep mode is as low as Wait mode only when the master clock is running at 500Hz with all peripherals clock off. The higher master clock frequency the higher power consumption in Sleep mode is. The microcontroller can be woken up in several microseconds in both Sleep and Wait mode. When waking up from Sleep mode, the core clock is re-enabled by PMC automatically. But In Wait mode, it needs more time. When waking up from Wait mode, the PMC automatically restarts the embedded 4/8/12 MHz fast RC oscillator and then switches the master clock on this clock. Normally, user needs to switch master clock to PLL clock to get higher frequency. Note: It is necessary to switch master clock to 4/8/12 MHz fast RC oscillator before entering Wait mode. In a short, the trade-off between wakeup time and power consumption must be taken into account when both Sleep mode and Wait mode can be used in the application. Generally, Wait mode can save more power than Sleep mode but Sleep mode has faster startup time than Wait mode. 3.4 Using Backup Mode In some applications, very low power consumption is necessary. In this case, the Backup mode can be considered. In Backup mode, timer can keep running and some important data can be stored in GPBR. Make sure that the Backup Supply domain is still powered when entering Backup mode. 14

4. Low Power Example A lowpower example in the Atmel SAM3S Software Package demonstrates how to enter/exit low power modes and how to measure the power consumption on each power modes using the Atmel SAM3S-EK board. The example code can be downloaded from the Atmel website: http://www.atmel.com/dyn/products/tools_card_mcu.asp?tool_id=4705 4.1 Hardware Setup This example runs on SAM3S-EK board: An RS-232 serial cable must be connected between UART(J7) and PC serial port To measure current consumption, an ampere meter has to be plugged instead of the VIN jumper 4.2 Running the Example Follow the steps to run the example: Build the program and download it into internal flash Open and configure a terminal application on PC: 115200 baud 8 bits of data No parity 1 stop bit No flow control Start the example, a menu will show on the terminal windows: This menu is divided into two parts: First part allows the user to change the master clock Second part allows the user to enter different power modes for measuring power consumption Select one of the options in the menu to perform the corresponding action. 5. References [1]. Atmel SAM3U/3S/3N datasheets, available at: http://www.atmel.com/dyn/products/datasheets_mcu.asp?family_id=605#2127 [2]. Cortex-M3 Technical Reference Manual, available at: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0337g/index.html 15

6. Revision History Doc. Rev. Date Comments 42160A 07/2013 Initial document release 16

Atmel Corporation 1600 Technology Drive San Jose, CA 95110 USA Tel: (+1)(408) 441-0311 Fax: (+1)(408) 487-2600 www.atmel.com Atmel Asia Limited Unit 01-5 & 16, 19F BEA Tower, Millennium 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 G.K. 16F Shin-Osaki Kangyo Building 1-6-4 Osaki, Shinagawa-ku Tokyo 141-0032 JAPAN Tel: (+81)(3) 6417-0300 Fax: (+81)(3) 6417-0370 2013 Atmel Corporation. All rights reserved. / Rev.: Atmel, Atmel logo and combinations thereof, Enabling Unlimited Possibilities, and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. ARM, Cortex and others are registered trademarks or trademarks of ARM Ltd. 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.