如果在程序中的某个位置设置断点,然后通过以下方式使设备进入待机模式: HAL_PWR_EnterSTANDBYMode();
当调试器仍保持与设备连接(且设备处于待机状态)时,若通过IDE停止调试会话或物理断开SWD连接器终止调试,该断点将在设备唤醒后依然存在。 即使调试器未连接,设备唤醒后仍会在之前设置的断点处停止运行,导致程序挂起。此问题在使用OpenOCD时不会出现。 测试环境:
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
|