Getting started with PWR

Revision as of 17:19, 10 July 2020 by Registered User
Under construction.png Coming soon

This article explain what is sleep/stop and standby low power mode and provide code examples !

1. Low power mode

By default, the microcontroller is in Run mode after a system or a power-on reset. Several low-power modes are available to save power when the CPU does not need to be kept running, for example when waiting for an external event. It is up to the user to select the mode that gives the best compromise between low-power consumption, short startup time and available wakeup sources. The main three low-power modes:

  • Sleep mode (Cortex core stopped, peripherals kept running)
  • Stop mode (all clocks are stopped)
  • Standby mode (only backup domain is powered)

2. SLEEP Mode

2.1. Definition

File:sleep mode.png

2.1.1. Use SLEEP mode with EXTI​

2.1.1.1. Objective
  • We use the EXTI setup from EXTI_overview
  • Learn how to setup SLEEP in HAL​
  • Create simple project with SLEEP mode with wake up on pin press​
2.1.1.2. Goal
  • Use project from EXTI_overview
  • Learn how to setup the SLEEP in HAL, and which events can wake up MCU​
  • Verify the correct functionality by measuring consumption​
2.1.1.3. HAL Library workflow summary

File:Sleep HAL.png

2.1.1.4. Open the project from EXTI_overview
  • Open the main.c
  • Add function suspend the Systick ( as we wakeup on any interrupt)
  • Add function to enter in SLEEP mode
  • Add function to resume the Systick on wakeup

File:SleepCode v2.1.png

2.1.1.5. Compile and flash
2.1.1.6. Measure consumption
  • Stop any debug session and do a full power cycle
  • Use an ampermeter on IDD connector (JP5 on NucleoF429ZI, for other board check User Manual)
  • Check consumption while in SLEEP mode
  • Press the button of the Nucleo, you can see the consumption variation

3. STOP Mode

3.1. Definition

File:stop mode.png

3.1.1. Use STOP mode with EXTI​

3.1.1.1. Objective
  • We use the EXTI setup from EXTI_overview
  • Learn how to setup STOP in HAL​
  • Create simple project with STOP mode with wake up on pin press​
3.1.1.2. Goal
  • Use project from EXTI_overview
  • Learn how to setup the STOP in HAL, and which events can wake up MCU​
  • Verify the correct functionality by measuring consumption​
3.1.1.3. HAL Library workflow summary

File:Stop HAL.png

3.1.1.4. Open the project from EXTI_overview
  • Open the main.c
  • Add function to enter in STOP mode
  • Reconfiguration of the clocking

File:STOP code.png

3.1.1.5. Compile and flash
3.1.1.6. Measure consumption
  • Stop any debug session and do a full power cycle
  • Use an ampermeter on IDD connector (JP5 on NucleoF429ZI, for other board check User Manual)
  • Check consumption while in STOP mode
  • Press the button of the Nucleo, you can see the consumption variation

4. STANBY Mode

4.1. Definition

File:standby mode.png

4.1.1. Use STANBY mode

4.1.1.1. Objective
  • For this lab create CubeMX project
  • For testing purpose enable LED PG14 on NucleoF429ZI(for other board check User Manual)
  • Learn how to setup STANDBY in HAL
  • Create simple project with STANDBY mode with wake up on pin
4.1.1.2. Goal
  • Learn how to setup the STANDBY in HAL, which events can wake up you
  • Verify the correct functionality by measuring consumption
4.1.1.3. HAL Library workflow summary

File:StandBy HAL.png

4.1.1.4. Open the project from EXTI_overview
  • Open the main.c
  • Add the clear of the wakeup flag ( without it, you will go in StandBy only once)

File:StandByCode1.png

  • Light on the LED
  • Wait 2 second
  • Enable the wakeup pin ( which is PA0 and connected to the blue button on NucleoF429ZI)
  • Add function to enter in STANDBY mode

File:StandByCode2.png

4.1.1.5. Compile and flash
4.1.1.6. Measure consumption
  • Stop any debug session and do a full power cycle
  • Use an ampermeter on IDD connector (JP5 on NucleoF429ZI, for other board check User Manual)
  • Check consumption while in STANDBY mode
  • Press the button of the Nucleo, you can see the consumption variation