2018-06-14 12:14 PM
I have a project (built using CubeMX) that puts the STM32F042K6 in Standby mode by calling HAL_PWR_EnterSTANDBYMode().
It behaves well and does what I expect. However, the documentation says 'SRAM and register contents are lost' in this mode.
I only noticed this after I'd written my code - and now I don't understand how it's working. Does the HAL function somehow take care of this for me? Or is SRAM really being preserved? Or am I just getting lucky?
If I read that warning right, I'd need to re-run all the initialization routines when I come out of standby mode to make sure my ADC/UART/GPIO/etc. are set properly. Is that right?
2018-06-14 02:48 PM
Do you debug? If so, then you have DBGMCU_CR.DBG_STANDBY=1 likely set by the debugger, and then you don't really go into STANDBY as the regulator for digital logic remains ON.
The reason for RAM/registers content loss is that in STANDBY the regulator is switched OFF, thus the logic is unpowered - that's the point, to reduce the static consumption and maintain power only for the absolutely necessary circuitry for the clock (RTC, IWDG) to survive and provide wakeup.
JW
2018-06-14 03:04 PM
No, I don't do any debugging - though I have 'Debug Serial Wire' enabled in my Cube project.
I'll try it without that setting to see if it makes a difference.
2018-06-14 05:17 PM
That didn't seem to make a difference. I also specifically called HAL_DBGMCU_DisableDBGStandbyMode() which clears the bit in question - but that also didn't seem to do anything.
My code 'seems' to go into Standby mode when I call
HAL_PWR_EnterSTANDBYMode()
- and we see a power drop from ~4 mA down to ~1mA. But we expected a much bigger drop.