ARM: single stepping Cortex-M7 enters pending exception handler
Information in this knowledgebase article applies to:
We noticed, that while single stepping the program code on a Cortex-M7 device, the debugger will always enter the exception handler of a pending interrupt rather than to continue stepping the program from the current PC. This is very inconvenient and makes debugging quite impossible. We don't see such a behaviour on Cortex-M3/M4 devices. So, what is wrong?
The debugger sets the DHCSR -> C_MASKINTS bit on every single step to make sure this step will not enter a interrupt handler. Unfortunately, this bit has a slightly different behaviour in the Cortex-M7 core with core revision r0p0 or r0p1. Setting it does not mask pending interrupts, as it does in other core revisions. So with the next step, the program enters the interrupt handler, which became pending while the program was halted before executing that next single step.
Unfortunately, the problem can't be resolved by the debugger. If you want to debug a specific portion of the program code where this happens, you may have to disable problematic recurring interrupts manually to debug properly.
Also, check if the device manufacturer offers updated revisions of the device with a Cortex-M7 core revision r0p2 or newer.
In MDK-ARM 5.16 we made an attempt to workaround the issue in our
ULINK2, ULINKpro and CMSIS_DAP debug drivers by setting the DHCSR
-> C_MASKINTS bit while the target is halted and not just for a
Last Reviewed: Tuesday, April 4, 2017
of your data.