cancel
Showing results for 
Search instead for 
Did you mean: 

How to optimize power consumption by SAI

HCohe.1
Associate III

I'm developing a battery powered application using the STM32WBMMG and working to minimize power consumption.  I'm using STM32Monitor-Power and X-NUCLEO-LPM01A to supply power to our custom board and measure current. The application periodically uses the SAI to generate audio (alert tones). If I comment out the call to MX_SAI1_Init() in main(), the average current measurement drops by 500uA so I'd like to keep the SAI disabled until it's needed. To that end, I added a call to HAL_SAI_DeInit() near the end of the initialization sequence in main() and bracketed audio generation with HAL_SAI_Init() & HAL_SAI_DeInit() calls. However, current measurement only decreases by ~100uA following the call to HAL_SAI_DeInit().

Here are the measured values (avg current over 10 seconds):

  1. With SAI fully initialized by MX_SAI1_Init(): I=3.4mA
  2. With call to MX_SAI1_Init() commented out: I=2.9mA
  3. With MX_SAI1_Init() followed by call to HAL_SAI_DeInit(): I=3.3mA

How can I properly set the SAI registers to obtain the optimal (500uA) power savings?

3 REPLIES 3

Cube is open source, so you can look at what is modified by those functions.

Alternatively read out and compare registers (SAI, related RCC, related GPIO) content.

JW

Piranha
Chief II

My guess is that the code does not disable the SAI/DMA peripheral clocks in RCC. But actually to save power there probably is no need to reset the peripherals and drivers. Just disable the SAI/DMA and disable the clocks in RCC accordingly. The peripherals and drivers will keep the state but will not consume the current.

As Piranha said, turn off the peripheral clock.

If you check the HAL init function, you will find something like this in the beginning:

__HAL_RCC_SAIx_CLK_ENABLE();

So make sure that in the DeInit function

__HAL_RCC_SAIx_CLK_DISABLE();

is called.