How to use DWT mechanism of cortex-m33 to obtain the corresponding instruction and accessed memory in the run time?

I used two registers to configure and monitor continuous memory being accessed, the code shows as following:

uint32 memory[1000];
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk |CoreDebug_DEMCR_MON_EN_Msk;
uint32_t * comp1 = 0xE0001030;
*comp1 = &memory[999];
DWT->FUNCTION1 = (0<<11)|1<<4|7;
uint32_t *comp0 = 0xE0001020;
*comp0 = &memory[0];
DWT->FUNCTION0 = (0 << 11) | 1<<4 | 5;

Then, every instruction writes the memory will trigger an exception and invoke the DebugMon_Handler.

What I want is to do is to obtain which instruction to write the memory in DebugMon_Handler and the exact memory address involved.

Any suggestions on how to obtain the exact instruction & memory address that triggers the interrupt?

Parents
  • From the armv8-m ARM, B12.4(Debug Event Behavior), the watchpoint will

    generate an  asynchronous debug events.

    "• Watchpoint debug events caused by a match in the DWT, including instruction address match watchpoints."

    So the PC value you catched in the debug monitor handler should be delay some

    instructions, but doesn't know how many instructions delayed(maybe depend on pipe line?).

    I thought it should save the address to MMFAR or BFAR, but it doesn't.

    Maybe ARM experts can give some ideas how to get the matched instruction?

    Br,

    Yingchun

Reply
  • From the armv8-m ARM, B12.4(Debug Event Behavior), the watchpoint will

    generate an  asynchronous debug events.

    "• Watchpoint debug events caused by a match in the DWT, including instruction address match watchpoints."

    So the PC value you catched in the debug monitor handler should be delay some

    instructions, but doesn't know how many instructions delayed(maybe depend on pipe line?).

    I thought it should save the address to MMFAR or BFAR, but it doesn't.

    Maybe ARM experts can give some ideas how to get the matched instruction?

    Br,

    Yingchun

Children
No data