cancel
Showing results for 
Search instead for 
Did you mean: 

Run-STOP3 test app only works when running debugger

EC.3
Associate III

Hi,

I have a test app for the U5, which is intended to sleep for a short period of time and wake for a short period time, not unlike the default PCC Sequence you can see in the CubeIDE IOC. It will toggle an output line when entering STOP3 mode and also when waking up. While the timing of wake v sleep is a bit off when the output line is measured using a logic analyzer, the app does seem to basically work.

The strange thing is that it only seems to work when run from the debugger. In other words, the GPIO is not toggled if the board is powered up and the debugger is not started. Any suggestions as to what this might be or things to try?

Thanks

4 REPLIES 4
EC.3
Associate III

I found an issue where the RTC-based wakeup timer callback is invoked early in the initialization process and eventually leads to a fault because some application-level timer code has not yet been initialized. Could be that the debugger introduces a timing change that avoids this problem.

Though after fixing that issue it still will not run outside of the debugger. I can start the debugger with no breakpoints, see the GPIO being toggled, stop the debugger - and the GPIO stops (and never restarts) toggling.

I updated it so that the mainloop will delay for 5s then start the STOP3-Run sequence, with GPIO output high while awake. Again, running in the debugger is fine. Without the debugger and just looking at the GPIO pin, it stays awake for 5s then goes to sleep and stays asleep. Is the debugger maintaining power to something that otherwise goes inactive in STOP3 that makes it look like it works?

Aime
ST Employee

Hi @EC.3 ,

 

Unlike Stop 2 where all I/O pins keep the same state as Run mode, in Stop 3 mode the the I/Os are by default in floating state. If the APC bit in the PWR_APCR register is set, the I/Os can be configured either with a pull-up (see PWR_PUCRx registers), or with a pull-down (see PWR_PDCRx registers), or can be kept in analog state if none of the PWR_PUCRx or PWR_PDCRx register is set. The pull-down configuration has highest priority over pull-up configuration in case both PWR_PUCRx and PWR_PDCRx are set for the same I/O (Please refer the reference manual for more details to the section 10.7.9 Stop 3 mode).

 

By default the debugger set the bits DBG_STANDBY and/or DBG_STOP in DBGMCU_CR. These bits, when set, maintain the clock and power to the processor while the device is in the corresponding low-power mode. The processor remains in Sleep mode, and exits the low-power mode in the normal way. Peripheral devices continue to operate, so the device behavior may not be identical to the one in the actual low-power mode. 

 

If in your application you did not reset these bits when you were using the debugger, that can explain why the GPIO toggled but you were not in Stop 3 mode.

What is your consumption in Stop 3 mode without the debugger? How does the devices wake up?

 

Best regards,

Aime

 

EC.3
Associate III

Thanks for your reply, Aime.

I might revisit STOP3 in the future, but in the meantime I switched to using STOP2. After dealing with a race condition related to enabling the RTC interrupt, I saw more consistent behavior with the GPIO output: high when awake, low when asleep. Using STOP2, I can see the output toggle as expected with or without using the debugger, as well as the current draw change as expected, as the MCU toggles every 5s between wake and STOP2.

Changing it back to STOP3, it gives the appearance of getting stuck in STOP3 when run outside the debugger, even with regards to the current draw. Meaning I see the current high and output high for 5s at startup then current goes low and output goes low, but never go back up again. It's as if the LSE-based RTC wakeup fails to wake it up.

This serves for now. I'll keep your info in mind if I do need to experiment with STOP3 again. Thanks.

Hi @EC.3 ,

 

Glad to hear that! 

Waking up from Stop 3 is a bit more different than the other modes.

Before entering in Stop 3  you have to:

  • Enable the corresponding WakeUp line for the RTC (refer to the table 97. PWR wake-up selection in the reference manual for more details)
  • Enable the RTC interrupt
  • Enable Stop 3 interrupt (PWR_S3WU_IRQn)

 

Please try the PWR_LPMODE_RTC example in the STM32U5 Cube package : STM32Cube_FW_U5_V1.3.0\Projects\NUCLEO-U575ZI-Q\Examples\PWR\PWR_LPMODE_RTC. It might help you!

 

Best regards,

Aime