Hi, my app (cortex m3) needs to set up a breakpoint directly from code, in order to jump to an interrupt when an instruction from a certain address is fetched. This WITHOUT using a debugger.
Any hint or tutorial? I think the only possible way is the patch block but it seems quite complicated.
You can use debug monitor exception for that:
- set MON_EN(bit 16) in DEMCR (0xE000EDFC)
- Set FPB comparator register 0-5 for instruction address, with bit 0 (ENABLE) set to 1, REPLACE (bit[31:30]) = b01/b10/b11 depending on address
- Set FPB comparator register 6-7 for literal data address, with bit 0 (ENABLE) set to 1 (bit[31:30] is ignored)
- Enable FPB (FPB control register bit 0 set to 1)
You also need to define your debug monitor handler.
Hi, it works!
When it jumps inisde my debug monitor handler though, I need to disable that address breakpoint, otherwise as soon as it exits the handler, the handler is called again ad so on. I suppose that's because the breakpoint is just before the instruction.
I'd like the handler to be called only the next time that my address is met. Any way to do that?
Thanks a lot
You need to do a single step with the breakpoint disabled, and then re-enable the breakpoint and resume.
To single step: set MON_PEND (bit 18) in DEMCR, and then exit debug monitor handler.