The ARM DWT (Data Watchpoint and Trace) is an optional feature of the ARM-Cortex-M, and many Cortex-M3, M4 and M7 devices have it implemented. With it comes a cycle counter which counts the cycles spent. In Cycle Counting on ARM Cortex-M with DWT I described an approach how the application on the target can access the cycle counter.
The MCUXpresso IDE shows that cycle counter in the Eclipse Registers view:
The NXP MCUXpresso IDE has implemented a custom extension to show the cycle counter register value as a pseudo register.
The screenshot above is with using the MCUXpresso IDE 10.2.0 on a FRDM-K64F (ARM Cortex-M4) using the LinkServer debug connection.
💡 As of MCUXpresso IDE 10.2.0 build 759, the P&E and SEGGER interface does not support that feature.
The other pseudo register is the ‘cycledelta’ one. this one shows the cycles since the last time the target was stopped. With doing source level stepping, this shows me directly the number of cycles spent for that step, same for assembly level stepping. In a similar way, I can measure the cycles spent in function with setting a breakpoint at the beginning and at the end of the function: simple and effective :-).
Happy counting 🙂