cancel
Showing results for 
Search instead for 
Did you mean: 

Standby mode in Cube project. Is SRAM really lost (STM32F042K6)

Jim Seymour
Senior
Posted on June 14, 2018 at 21:14

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?

3 REPLIES 3
Posted on June 14, 2018 at 23:48

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

Jim Seymour
Senior
Posted on June 15, 2018 at 00:04

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.

Posted on June 15, 2018 at 00:17

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.