2025-07-27 10:07 AM
I am using an SD card with STM32F415. The MCU periodically enters STOP mode.
Currently, I observe the following behaviour in the IDE related to SDIO:
- Before enabling SDIO for the first time, the current consumption in STOP mode is as expected (around 180 µA), and the 48 MHz clock is greyed out in the Clock Configuration diagram in the IDE.
- As soon as I enable SDIO in SD 1-bit mode, the 48 MHz clock becomes active in the Clock Configuration diagram, and the current consumption in STOP mode jumps up by 1 mA. This is true even if I disable the call to MX_SDIO_SD_Init() in main().
- When I later disable the SDIO interface in the configurator, the 48 MHz clock remains active, and the current consumption in STOP mode remains with the additional 1 mA introduced when enabling the SD card for the first time.
I see no way of disabling the 48 MHz clock, either temporarily (before going to STOP mode) or permanently (by disabling the SDIO altogether in the IDE). I suppose this is also the reason why I can't eliminate that additional mA in STOP mode.
What is the correct way to turn off all the SDIO-related peripherals before switching to STOP mode to save as much power as possible?
2025-07-27 12:50 PM
My recommendation would be to study the Reference Manual for your stm33, to try to understand what the stm32 libraries are doing and why.
When ST’s HAL library function to start SDIO is called, it knows it needs the 48MHz clock, so it enables that clock.
But other peripherals might also use the 48MHz clock (off the top of my head, I think it is often used for the true-random-number generator and there could be others).
The HAL library function to turn off SDIO doesn’t know if you’re using the 48 MHz clock for other peripherals so it doesn’t stop that oscillator.
That’s my understanding. Only you know your entire system so only you can decide if it is safe to turn it off.
2025-07-28 12:31 PM - edited 2025-07-28 1:04 PM
My recommendation would be to study the Reference Manual for your stm33, to try to understand what the stm32 libraries are doing and why.
I agree and I did read the RM. However, the issue here is that I still experience consequences (an additional 1 mA of consumption) even when I disable the relevant libraries.
But other peripherals might also use the 48MHz clock (off the top of my head, I think it is often used for the true-random-number generator and there could be others).
The HAL library function to turn off SDIO doesn’t know if you’re using the 48 MHz clock for other peripherals so it doesn’t stop that oscillator.
You are right, I overlooked something here: I had the RNG enabled, which is why the 48 MHz clock remained active even after I disabled SDIO. However, even when I disable both the RNG and the SDIO — which reverts the 48 MHz clock to grey in the diagram — I still have that additional 1 mA! The IDE behaves as if there were a latching mechanism that, once "something" (SDIO? / 48MHz clock? / other?) is activated for the first time, remains on and keeps the higher consumption going forever, even if I revert the changes that caused the initial consumption increase.