13 Tutorial 3 - Using the Power Consumption Calculator to optimize the embedded application consumption and more ¶
FATFS_UnLinkDriver(SDPath);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */ while (1)
13 Tutorial 3 - Using the Power Consumption Calculator to optimize the embedded application consumption and more ¶
13.1 Tutorial overview ¶
This tutorial focuses on STM32CubeMX Power Consumption Calculator (Power Consumption Calculator) feature and its benefits to evaluate the impacts of power-saving techniques on a given application sequence.
The key considerations to reduce a given application power consumption are:
Reducing the operating voltage
Reducing the time spent in energy consuming modes
It is up to the developer to select a configuration that gives the best compromise between low-power consumption and performance.
Maximizing the time spent in non-active and low-power modes
Using the optimal clock configuration
The core should always operate at relatively good speed, since reducing the operating frequency can increase energy consumption if the microcontroller has to remain for a long time in an active operating mode to perform a given operation.
Enabling only the peripherals relevant for the current application state and clock-gating the others
When relevant, using the peripherals with low-power features (e.g. waking up the microcontroller with the I2C)
Minimizing the number of state transitions
Optimizing memory accesses during code execution
Prefer code execution from RAM to flash memory
When relevant, consider aligning CPU frequency with flash memory operating frequency for zero wait states.
The following tutorial shows how the STM32CubeMX Power Consumption Calculator feature can help to tune an application to minimize its power consumption and extend the battery life.
Note: The Power Consumption Calculator does not account for I/O dynamic current consumption and external board components that can also affect current consumption. For this purpose, an “additional consumption” field is provided for the user to specify such consumption value.
13.2 Application example description ¶
The application is designed using the NUCLEO-L476RG board, based on an STM32L476RGTx device, and supplied by a 2.4 V battery.
The main purpose of this application is to perform ADC measurements and transfer the conversion results over UART. It uses:
Multiple low-power modes: Low-power run, Low-power sleep, Sleep, Stop and Standby • Multiple peripherals: USART, DMA, Timer, COMP, DAC and RTC
The RTC is used to run a calendar and to wake up the CPU from Standby when a specified time has elapsed.
The DMA transfers ADC measurements from ADC to memory
The USART is used in conjunction with the DMA to send/receive data via the virtual COM port and to wake up the CPU from Stop mode.
The process to optimize such complex application is to start describing first a functional only sequence then to introduce, on a step by step basis, the low-power features provided by the STM32L476RG microcontroller.
13.3 Using the Power Consumption Calculator ¶
13.3.1 Creating a power sequence ¶
Follow the steps below to create the sequence (see Figure 651):
Launch STM32CubeMX.
Click new project and select the Nucleo-L476RG board from the Board tab.
Click the Power Consumption Calculator tab to select the Power Consumption Calculator view. A first sequence is then created as a reference.
Adapt it to minimize the overall current consumption. To do this:
Select 2.4 V VDD power supply. This value can be adjusted on a step by step basis (see Figure 652).
Select the Li-MnO2 (CR2032) battery. This step is optional. The battery type can be changed later on (see Figure 652).
Figure 651. Power Consumption Calculation example ¶
Figure 652. VDD and battery selection menu
Enable the Transition checker to ensure the sequence is valid (see Figure 652). This option allows verifying that the sequence respects the allowed transitions implemented within the STM32L476RG.
Click the Add button to add steps that match the sequence described in Figure 652.
By default the steps last 1 ms each, except for the wake-up transitions preset using the transition times specified in the product datasheet (see Figure 653).
Some peripherals for which consumption is unavailable or negligible are highlighted with * (see Figure 653).
Click the Save button to save the sequence as SequenceOne.
The application consumption profile is generated. It shows that the overall sequence consumes an average of 2.01 mA for 9 ms, and that the battery lifetime is only four days (see Figure 654).
Figure 654. sequence results before optimization
13.3.2 Optimizing application power consumption ¶
Let us now take actions to optimize the overall consumption and the battery lifetime. These actions are performed on steps 1, 4, 5, 6, 7, 8, and 10.
The next figures show on the left the original step, and on the right the step updated with optimization actions.
Step 1 (Run) - Findings ¶
All peripherals are enabled although the application requires only the RTC.
Actions
Lower the operating frequency
Enable only the RTC peripheral
To reduce the average current consumption, reduce the time spent in this mode
Result
The current is reduced from 9.05 to 2.16 mA (see Figure 655).
Figure 655. Step 1 optimization
Step 4 (Run, RTC) - Action
Reduce the time spent in this mode to 0.1 ms
Step 5 (Run, ADC, DMA, RTC) ¶
Actions
Change to Low-power run mode
Lower the operating frequency
Results
The current consumption is reduced from 6.17 mA to 271 µA (see Figure 656).
Figure 656. Step 5 optimization
Step 6 (Sleep, DMA, ADC, RTC) ¶
Actions
Switch to Lower-power sleep mode (BAM mode)
Reduce the operating frequency to 2 MHz
Results
The current consumption is reduced from 703 µA to 93 µA (see Figure 657).
Figure 657. Step 6 optimization
Step 7 (Run, DMA, RTC, USART) ¶
Actions
Switch to Low-power run mode
Use the power efficient LPUART peripheral
Reduce the operating frequency to 1 MHz using the interpolation feature
Results
The current consumption is reduced from 1.92 mA to 42 µA (see Figure 658).
Figure 658. Step 7 optimization
Step 8 (Stop 0, USART) - Actions ¶
Switch to Stop1 low-power mode
Use the power-efficient LPUART peripheral
Results
The current consumption is reduced (see Figure 659).
Figure 659. Step 8 optimization
Step 10 (RTC, USART) - Actions ¶
Use the power-efficient LPUART peripheral
Reduce the operating frequency to 1 MHz
Results
The current consumption is reduced from 1.89 mA to 234 µA (see Figure 660).
The example given in Figure 661 shows an average current consumption reduction of 155 µA.
See Figure 661 for the overall results: 7 ms duration, about two months battery life, and an average current consumption of 165.25 µA.