2022-11-10 07:56 AM
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):
How can I properly set the SAI registers to obtain the optimal (500uA) power savings?
2022-11-10 09:29 AM
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
2022-11-10 04:07 PM
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.
2022-11-10 10:17 PM
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.