Library 39- Power consumption modes for STM32F4

For library 39, I made a low power modes library. This allows you to simple put STM32F4 into SLEEP, STOP or STANDBY mode. Point of this modes is simple. You want decrease current on device. If you are working on battery project, this will be very helpful.

You can set current down to about 2uA with proper low power mode.

I will tell you only the highlights of all 3 power down modes in this post. For detailed informations, check ST’s manual here.

STM32F4 Power consumption image from ST

STM32F4 Power consumption image from ST

Library

Features

  • Enable SLEEP mode
  • Enable STOP mode
  • Enable STANDBY mode
    • You can also test, if system was reset because of wakeup from Standby mode.
  • Enable/disable wakeup pin, pin PA0

Dependencies

  • CMSIS
    • STM32F4xx
    • STM32F4xx RCC
    • STM32F4xx PWR
  • TM
    • TM DELAY
    • defines.h
STM32F4 Description
PA0 If STM32F4 is in standby mode, rising edge on this pin will wake him up if it is activated.

STM32F4 power consumption modes

Highlights below are from st’s manual from their website.

SLEEP mode

  • Cortex-M4 core is stopped.
  • Peripherals kept running.
  • How to enter this mode?
    • Look for example 1 below.
  • How to exit this mode?
    • Any peripheral interrupt acknowledged by the nested vectored interrupt controller (NVIC).
      • Systick timer will also wake up MCU!
    • After exit, MCU continues where it stopped.

STOP mode

  • All clocks in 1.2V domain are stopped.
  • PLL, HSI and HSE RC oscillators disabled.
  • Internal SRAM and register contents are preserved.
  • Voltage regulator in low-power mode.
  • How to enter this mode?
    • Look for example 2 below.
  • How to exit this mode?
    • Any EXTI Line (Internal or External) configured in Interrupt/Event mode.
    • After exit, MCU continue there where it stopped. HSI is used for system core clock, but my library set it back to PLL as source.

STANDBY mode

  • Cortex-M4 deepsleep mode.
  • Voltage regulator disabled.
  • 1.2V domain consequently powered off.
  • PLL, HSI and HSE RC oscillators disabled.
  • SRAM and register contents are lost except for the RTC registers, RTC backup registers, backup SRAM and Standby circuitry.
  • How to enter this mode?
    • Look for example 3 below.
  • How to exit this mode?
    • Wakeup pin rising edge.
    • RTC alarm (Alarm A and B) and wakeup.
    • Tamper and time-stamp event.
    • External reset in NRST pin.
    • IWDG reset.
    • After exit, STM32F4xx reset.

VBAT mode

  • Main digital supply is turned off.
  • The circuit is supplied through VBAT pin which should be connected to an external supply voltage (a battery or any other source).
  • RTC is running in this mode.
  • How to enter this mode?
    • If you disable main power and put supply voltage on VBAT pin, then MCU will be in VBAT mode.
  • How to exit this mode?
    • Put power supply on main Vdd pins.

Note

If you put your STM32F4 into low power mode, it will become unavailable for normal programming. You will have to program it under reset mode or wake it up before programming.

Functions and enumerations

Example 1

This example will put STM32F4 into sleep mode.

  • RTC is configured with internal clock to generate wakeup interrupts every 10 seconds.
  • After STM is wake, it will toggle green LED 20 times (10 times on, 10 times off) and MCU will go to SLEEP mode.
  • Each time MCU will be waked up, RED led will be toggled.
  • If you put Ammeter on IDD pins on STM32F4/29-Discovery or Nucleo board, you will see how current vary.

Example 2

  • RTC is configured with internal clock to generate wakeup interrupts every 10 seconds
  • After STM is wake, it will toggle green LED 20 times (10 times on, 10 times off) and MCU will go to STOP mode
  • Each time MCU will be waked up, RED led will be toggled.
  • If you put Ammeter on IDD pins on STM32F4/29-Discovery or Nucleo board, you will see how current vary.
  • Main difference between SLEEP and STOP mode is that in sleep mode only processor sleep, peripherals work, in STOP mode everything is stopped, except EXTI.

Example 3

  • RTC is configured with internal clock to generate wakeup interrupts every 10 seconds
  • After STM is wake, it will toggle green LED 20 times (10 times on, 10 times off) and MCU will go to STANDBY mode
  • Each time MCU will be waked up, RED led will be toggled.
  • If you put Ammeter on IDD pins on STM32F4/29-Discovery or Nucleo board, you will see how current vary.
  • RED led should never be ON, because MCU will reset after wakeup
  • RED led will toggle, when MCU will reset after wakeup from MCU
    • If you reset system with “Reset button”, then RED led should not be toggled
  • You want wake up device if you press the button (rising edge on PA0 pin) or waiting for RTC to make it every 10 seconds for you

All examples are available separately on Github, download library below.

tilz0R

Owner of this site. Application engineer, currently employed by STMicroelectronics. Exploring latest technologies and owner of different libraries posted on Github.

You may also like...