AnsweredAssumed Answered

L152RE, entering standby via HAL call, execution continues after WFI - huh?

Question asked by mcygnus on Mar 12, 2016
Latest reply on Mar 14, 2016 by mcygnus
I'm encountering a very bizarre behavior with standby.

My code enters standby using HAL_PWR_EnterSTANDBYMode(). At power-on, it enters standby properly, comes out correctly after one intentional IWDG event (the reasons for which I can't get into due to confidentiality issues), enters standby properly a second time, and comes out correctly again after a WKUP.

Then, in response to a button press, it's supposed to go into standby again... only it doesn't. In this third case, execution continues after the WFI instruction. Yes, I mean that literally - I can step over the WFI instruction itself, inside the HAL call - NO reset occurs. I've never seen this before.

Everything was working fine, then I implemented a multi-task watchdog scheme and this started to happen. I can't exactly pin down an answer to "what did you change?" due to the extent of the additions, but the added watchdog scheme does not actually make use of the IWDG yet; what makes it even more odd is the lack of a reset after the WFI.

Platform, etc:
- STM32L152RET6 rev A silicon
- IAR EWARM 7/50.2.10505
- STM32CubeMX v. 4.12.0
- There's an RTOS, but I can't be more specific

The part that has me utterly flummoxed is watching execution continue after the WFI with no reset. I have not found information concerning any cases where execution could continue without a reset, when the settings required for entry into standby / Cortex-M3 deepsleep mode are done.

HAL_PWR_EnterSTANDBYMode() sets the PDDS bit in PWR_CR and the SLEEPDEEP flag in the SCR prior to the WFI; my own code clears the WUF bit in PWR_CSR shortly after execution begins and uses no RTC wakeup sources.

Is anyone aware of any situation where standby entry will NOT occur on a WFI and execution will continue with no reset?

I've even tried explicitly disabling the WKUP source associated with my button, clearing the WUF, and re-enabling the button WKUP, all just before the HAL standby call, with no change.

I'm not even sure where to go next. There's a mention of a standby-related issue in the errata for rev. A silicon, but it doesn't describe this scenario (execution continuing past WFI).

Many, many thanks in advance for any relevant clues!

Outcomes