2021-03-17 07:26 AM
If you put a breakpoint somewhere within the program and then put your device in standby mode via:
HAL_PWR_EnterSTANDBYMode();
While the debugger is still connected to the device (and the device is in standby mode), if you terminate the debugging session either by stopping it in the IDE or by disconnecting the SWD connector physically the breakpoint will persist even after the device wakes up. Meaning that after wakeup, even if the debugger isn't attached, the device will stop on that set breakpoint and will just hang there. This problem does not happen with OpenOCD.
Tested with STM32L486JG
and
STM32CubeIDE
Version: 1.6.0
Build: 9614_20210223_1703 (UTC)
Here is a repro for it:
HAL_GPIO_WritePin(led_red_GPIO_Port, led_red_Pin, GPIO_PIN_SET);
HAL_Delay(1000); // Breakpoint here
HAL_GPIO_WritePin(led_red_GPIO_Port, led_red_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(led_green_GPIO_Port, led_green_Pin, GPIO_PIN_SET);
HAL_Delay(1000);
HAL_PWR_EnterSTANDBYMode(); // After this one the debugging session is intentionally ended, when the device wakes up it will stop on the first breakpoint and the LED will keep being lit red