STM32 Standby Mode & Wakeup Pins/Sources

In this tutorial, we’ll discuss The STM32 Standby Mode, how to enter standby mode in STM32 microcontrollers, and how to exit from standby mode (Wakeup pin, RTC, etc) with some code examples and a full test project. Without further ado, let’s get right into it!

Table of Contents

  1. STM32 Standby Mode
  2. STM32 Enter Standby Mode
  3. STM32 Wakeup (Exit) Standby Mode
  4. STM32 Standby Mode Example Code Project
  5. Wrap Up

STM32 Standby Mode

The STM32 Standby mode is used to achieve the lowest power consumption with a brown-out reset. The internal regulator is switched OFF so that the VCORE domain is powered off. The PLL, the MSI RC, the HSI16 RC, and the HSE crystal oscillators are also switched OFF.

The RTC can remain active (Standby mode with RTC, Standby mode without RTC). Brown-out reset (BOR) always remains active in the Standby mode. The state of each I/O during standby mode can be selected by software: I/O with internal pull-up, internal pull-down, or floating.

The system can be woken up from standby mode using a SYS_WKUP pin, an RTC event (alarm or timer), IWDG, or an external reset in the NRST pin. After waking up from Standby mode, program execution restarts in the same way as after a Reset (boot pin sampling, option bytes loading, reset vector is fetched, etc.).

STM32 Standby Mode

For the STM32L432KC target microcontroller, in Standby Mode, the current consumption is:

  • Standby Mode at 25°C and VDD = 3V, the current consumption should be 90nA

To put things into perspective, this same target microcontroller (STM32L432KC) draws 72μA of current while operating in the DeepSleep (Low-Power Sleep) Mode. Even in Stop2 Mode, the same target microcontroller draws 1.23μA of current. Therefore, putting our microcontroller in the Standby Mode will significantly reduce current consumption.

❕ Note

When exiting Standby or Shutdown mode, all registers in the VCORE domain are set to their reset value. So it does lose context and waking up is similar to booting up after a sys reset.


STM32 Enter Standby Mode

By entering Standby Mode, the STM32 microcontroller loses context and all CPU registers’ content, so make sure you’ve handled all the logic operations needed before going into this mode.

#1

If you intend to wake the system up using a system wake-up (WKUP) pin, add the following line of code to clear the wake-up flag. Otherwise, standby mode will only be entered once.

Do the same in the case of wakeup using the RTC timer.

#2

Make sure you’ve enabled the system wakeup pin (WKUP1, or 2, etc..). In case of using RTC wakeup, make sure it’s also enabled as shown below.

#3

The last step is to enter the Standby Mode by calling the function below.


STM32 Wakeup (Exit) Standby Mode

When the STM32 microcontroller wakes up from Standby Mode, it’s like booting up after a complete system reset. The firmware execution starts from the very beginning, all previous context is lost and the system starts fresh. The only difference to tell whether it’s a clean boot up from a reset or a wakeup from standby is the SBF status flag in the PWR power control/status register (PWR_CSR).

The STM32 microcontroller can wakeup from standby mode by a WKUP pin rising edge, RTC alarm (Alarm A and Alarm B), RTC wakeup, tamper event, timestamp event, hardware reset on the NRST pin, or IWDG reset.

Auto Wakeup from Standby mode can be achieved using the internal RTC timer.

❕ Note

To learn more about Reset Reason Identification in STM32 microcontrollers, check out the linked tutorial.


STM32 Standby Mode Example Code Project

In this example project, we’ll configure our STM32L432KC microcontroller to run at full speed (80MHz) for 1 second. Then it’ll automatically switch to Standby Mode. The WKUP1 pin will be used to wake up the system.

Step #1

Open STM32CubeMX, create a new project and select the target microcontroller. For me, it’s (STM32L432KC)

Step #2

Enable the system wake-up pin (WKUP1 pin).

STM32 Standby Mode Wakeup Pin WKUP1

Step #3

Go to the Clock configuration page and select the internal HSI+PLL as a clock source to give you the maximum SysClk of 80MHz (in my case). This is the base full-speed run mode.

You can however, select the internal MSI which can give you a low-frequency clock source (2MHz down to 100kHz), if needed.

STM32 Low Power Run Mode Example Clock Configuration

Step #4

Name & Generate The Project Initialization Code For CubeIDE or The IDE You’re Using.

Step #5

While connecting the WKUP1 pin, make sure it’s Pulled-Down externally with a 10k ohm resistor. Hook up a push button to give it HIGH signal on each button click.

STM32 Standby Mode Example Code

Here is The Application Code For This LAB (main.c)


Required Parts For STM32 Examples

All the example Code/LABs/Projects in this STM32 Series of Tutorials are done using the Dev boards & Electronic Parts Below:

QTY.Component NameAmazon.comAliExpresseBay
1STM32-F103 BluePill Board (ARM Cortex-M3 @ 72MHz)AmazonAliExpresseBay
1Nucleo-L432KC (ARM Cortex-M4 @ 80MHz)AmazonAliExpresseBay
1ST-Link V2 DebuggerAmazonAliExpresseBay
2BreadBoardAmazonAliExpresseBay
1LEDs KitAmazonAmazonAliExpresseBay
1Resistors KitAmazonAmazonAliExpresseBay
1Capacitors KitAmazonAmazonAliExpress & AliExpresseBay & eBay
1Jumper Wires PackAmazonAmazonAliExpress & AliExpresseBay & eBay
1Push ButtonsAmazonAmazonAliExpresseBay
1PotentiometersAmazonAliExpresseBay
1Micro USB CableAmazonAliExpresseBay

★ Check The Links Below For The Full Course Kit List & LAB Test Equipment Required For Debugging ★

Download Attachments

You can download all attachment files for this Article/Tutorial (project files, schematics, code, etc..) using the link below. Please consider supporting our work through the various support options listed in the link down below. Every small donation helps to keep this website up and running and ultimately supports the whole community.


Wrap Up

In conclusion, we’ve explored the STM32 Standby Mode, what standby mode does to reduce the current consumption, and what are the current consumption numbers expected from this mode using the (STM32L432KC) target microcontroller.

We’ve also explored how to enter and exit (wake-up) from standby mode in STM32 microcontrollers. You can build on top of the provided example code project and integrate it into your system. You can also check the rest of the tutorials in this series to learn more about other low-power modes in STM32 microcontrollers.

This Tutorial is Part of The Following Multi-Part Tutorial Series:

Share This Page With Your Network!
Join Our +25,000 Newsletter Subscribers!

Stay Updated With All New Content Releases. You Also Get Occasional FREE Coupon Codes For Courses & Other Stuff!

Photo of author
Author
Khaled Magdy
Embedded systems engineer with several years of experience in embedded software and hardware design. I work as an embedded SW engineer in the Automotive & e-Mobility industry. However, I still do Hardware design and SW development for DSP, Control Systems, Robotics, AI/ML, and other fields I'm passionate about.
I love reading, writing, creating projects, and teaching. A reader by day and a writer by night, it's my lifestyle. I believe that the combination of brilliant minds, bold ideas, and a complete disregard for what is possible, can and will change the world! I will be there when it happens, will you?

Leave a Comment