I am debugging with cortex m7, i found that when I halt the CPU, the timer's counter value still upward increases. After reading it's reference maunal, I found a register that can stop timer's clock feed when the debugger halts the CPU. However, even I configure this register, I still got counter value increases for about 15 in disassembly single step(timer clock is same as cpu's). Is this the same for all microcontroller? So I can only see the right behavior in simulator? Thank you!


1 Answer 1


This sort of detail varies considerably between microcontrollers. This specifically has to do with how exactly debugging and single stepping is implemented.

Manufacturers don't want to add a lot of hardware just for debugging, because that burdens the case where a large company wants to buy 100 k pieces at a time for a production run. As a result, all kinds of clever schemes exist for re-using existing hardware. One common scheme is to have the part execute special code to help implement the debugging interface. To the processor, this is just code, so counters and the like keep running.

The switch to stop the counter during single stepping in your case probably only means the peripherals are shut off when the chip is idle, not when the debug code is running and communicating with the debugger. It may be in your case that this debug code takes 15 cycles per single step.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.