Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 70

Understanding Low-Power Modes from Device Datasheets

Recommended resources

Introduction

In our previous lesson, we tackled one of the most critical aspects of system stability: detecting and debugging stack overflows. By learning to use static and dynamic analysis tools, you've made your firmware significantly more robust. Now that we can build stable systems, our next focus as professional engineers is to make them efficient.

Welcome to the first lesson of our module on Power Management and Optimization. In many embedded applications, especially battery-powered devices and automotive electronics, minimizing power consumption is not just a feature—it's a core requirement. An idle MCU that draws unnecessary current can drain a car battery over time or severely limit the operational life of a portable sensor.

This lesson focuses on a foundational skill: understanding the tools your microcontroller provides for power saving. Our goal is to identify the different low-power modes (Sleep, Stop, and Standby) directly from the device datasheet. Mastering this is a non-negotiable skill, as the datasheet is the ultimate source of truth for the hardware you are programming.


1. The Importance of Low-Power Design

In a typical embedded system, the microcontroller spends a surprisingly large amount of its time doing nothing but waiting for an event—a button press, a sensor reading to become available, or a timer to expire. In a simple while(1) loop with polling, the CPU is running at full speed, executing millions of "do-nothing" instructions and wasting power.

Low-power modes allow us to put the MCU into various states of "sleep" to conserve energy while it's idle, waking it up only when there is work to do. Each mode represents a different trade-off between power savings and wake-up time.


2. Consulting the Primary Source: The Datasheet

An embedded systems engineer must be proficient at navigating and interpreting device datasheets. All marketing materials and tutorials are secondary to the official documentation from the manufacturer. Let's start by finding the descriptions of the low-power modes for your STM32F103C8T6.

Datasheet - STM32F103x8 STM32F103xB

The datasheet for your MCU contains the definitive description of its low-power capabilities. We will start here to build our foundational knowledge.

Please find and read section 2.3.12 'Low-power modes' (it should be around page 16 or 17). This short section is the manufacturer's official description of Sleep, Stop, and Standby modes. As you read, focus on identifying: What happens to the CPU in each mode? What is the state of the clocks and voltage regulator? Are the contents of SRAM and registers retained? What events can wake the device up from each mode?

The datasheet provides dense, technically precise information. Now, let's supplement that with a more conceptual explanation to help visualize what's happening inside the chip.


3. Understanding the Modes Conceptually

The datasheet tells us what happens, but a visual or conceptual model can help explain why the modes differ. The following video gives an excellent high-level overview.

Sleep & Low Power Modes with STM32

This video from '1s and 0s' clearly explains the hierarchy of the low-power modes. Although it uses an STM32F4, the core concepts of Sleep, Stop, and Standby are identical across the STM32 family.

Watch the segment from 02:02 to 04:42. The presenter does a great job of explaining what gets turned off in each mode (CPU clock, domain clocks, oscillators, regulator) and the critical consequence for waking up—whether the MCU resumes execution or reboots completely.

Based on the datasheet and the video, we can now define the characteristics of each mode.

Sleep Mode

  • What happens? Only the CPU clock is stopped. The rest of the chip—peripherals, memories, and their clocks—remains fully powered and active.
  • Power Savings: Modest. Since only the CPU core is off, the power reduction is limited.
  • Wake-up: Extremely fast. Any configured interrupt (from a timer, UART, etc.) can wake the CPU. Execution resumes instantly where it left off.
  • Use Case: Ideal for very short idle periods where you need peripherals to keep running and require an immediate response.

Stop Mode

  • What happens? This is a much deeper sleep. The CPU is stopped, and all high-speed clocks (HSI and HSE oscillators, PLL) are disabled. However, the main voltage regulator can be put into a low-power mode, and the contents of SRAM and all CPU registers are retained.
  • Power Savings: Significant. Shutting down the main oscillators provides a major reduction in power consumption.
  • Wake-up: Slower than Sleep mode. The MCU can only be woken by specific external interrupt (EXTI) lines, such as a pin change, an RTC alarm, or the USB peripheral. Upon wake-up, the high-speed clocks must be re-initialized before the CPU can run at full speed, but execution still resumes from where it stopped.
  • Use Case: The most common low-power mode. Perfect for applications that sleep for seconds or minutes and need to wake up periodically (e.g., from an RTC alarm) or on an external event (e.g., a button press), while retaining their full state.

Standby Mode

  • What happens? This is the deepest sleep, offering the lowest possible power consumption. The main voltage regulator is completely turned off, powering down the entire 1.8V core domain.
  • Power Savings: Maximum. The chip is almost entirely off, drawing only microamps of current.
  • Consequence: Because the core is powered down, all SRAM and register contents are lost. The only things that can be preserved are the backup registers and the Real-Time Clock (RTC), which have a separate power domain (VBAT).
  • Wake-up: Longest wake-up time. Waking from Standby is equivalent to a full system reset. The MCU does not resume execution; it reboots from the beginning. The only way to know you woke from Standby (as opposed to a cold boot) is by checking a specific status flag (SBF - Standby Flag) in a power control register.
  • Use Case: For applications that must survive on a battery for months or years, sleeping for very long periods and only waking on rare, specific events (e.g., an external RTC alarm or a user pressing a "wake" button).

4. A Comprehensive Comparison

To tie everything together, it's useful to see all the characteristics side-by-side. The following article provides an excellent summary table specifically for the STM32F103, which will serve as a great reference.

STM32 Low Power Modes: Sleep, Stop, and Standby Explained

Let's review a well-written article that summarizes these concepts and presents them in clear comparison tables.

Please read these two key parts of the article: Start with the section titled 'STM32 Low Power Modes Explained'. Pay special attention to the table under 'STM32 Power Consumption in Low Power Modes,' which gives typical current-draw values for a Blue Pill board like yours. Next, scroll down to the final section, 'Comparison of STM32 Low-Power Modes'. This table is a perfect summary of the trade-offs and is an excellent reference to save for later.

This table powerfully illustrates the trade-off you must make as an engineer: the deeper the power savings, the more state is lost and the longer it takes to wake up and respond.

STM32 Low-Power Mode Summary Table
This table from an STM32 reference manual provides a concise summary of the characteristics of each low-power mode, including entry conditions, wake-up sources, and the status of clocks and regulators.

Conclusion

In this lesson, you've taken a critical first step into power management by learning to identify and differentiate the low-power modes available on your STM32 microcontroller. You've practiced the essential engineering skill of extracting this information directly from the official datasheet and reinforced it with conceptual guides.

Key Takeaways:

  • Sleep Mode: The lightest sleep. Only the CPU is stopped. Peripherals remain active, wake-up is instant, but power savings are modest.
  • Stop Mode: A deep sleep that retains state. High-speed clocks are off, but SRAM and registers are preserved. It offers a great balance of significant power savings and a reasonably fast, resume-from-halt wake-up.
  • Standby Mode: The deepest sleep with the lowest power consumption. The core is powered down, meaning SRAM is lost. Waking from Standby causes a full system reset.
  • The choice of mode is a crucial design decision based on the application's requirements for power consumption, response time, and state retention.

Preview of the Next Lesson:

Knowing what the modes are is the first step. The next is learning how to use them. In our next lesson, "Implement interrupt-driven logic to replace polling and enable low-power modes," you will put this theory into practice. We will take a simple polling-based program, refactor it to be interrupt-driven, and implement Sleep mode to drastically reduce its power consumption. You will also prepare to use your multimeter to measure these power savings yourself.