I'm trying to debug some code in µVision V5.36.0.0 on an STM32F730V8Tx using an ST-Link debugger.
Unfortunately, the code doesn't fit into the device unoptimized, so I'm forced to try to debug it built with -O2. This will obviously cause some debugging issues, but the issue I'm having doesn't seem like it should be happening regardless of optimization level.
If I set a breakpoint (and I know that it's a valid place to set a breakpoint even with optimization because the IDE tells you while debugging if the breakpoint location doesn't exist in the built code) and execute the firmware, the debugger definitely hits the breakpoint and stops. I can tell because the Stop button on the toolbar becomes disabled the the Run button on the toolbar becomes enabled.
However, immediately thereafter, the Run button becomes disabled again, and the Stop button becomes enabled, and the code resumes running, all without any intervention from me.
Does anybody know what could be happening here?
Thanks.
Sounds like a watchdog running in the background and reseting your device. Try setting another breakpoint on main().
Yup, that was it. Wasn't expecting that, since other MCUs I've used don't do watchdog resets while halted in the debugger.
Thanks!
You can disable watchdog running while CPU is halted, for example for IWDG I use code below:DBGMCU->APB1FZ |= DBGMCU_APB1_FZ_DBG_IWDG_STOP;