2024-02-01 01:10 AM
Is it OK to use DWT CYCCNT to count individual instruction cycles when stepping instructions (si) with gdb ? I wonder how many cycles a branch takes when it is taken.
2024-02-01 06:05 AM
Hello @mete,
Thank you for your question !
DWT->CYCCNT is part of the ARM core. When implemented and enabled, CYCCNT increments on each cycle of the processor clock. When the counter overflows it wraps to zero, transparently. However, CYCCNT does not increment when the processor is halted in Debug state.
Kind Regards,
Pierre
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-02-01 07:54 AM
I understand it is not continuously increasing like a free running counter in debug state, which is reasonable since the core is not executing anything. If I am looking at the correct address (0xE0001004), it actually increments when instructions are stepped in the debugger. What I wonder is, for example for branch instructions, when the branch is taken, the instruction is specified as taking 1+P cycles where P=1..3 and it depends on a few things. I wonder if I step debug, the CYCCNT shows this behaviour correctly, i.e. if branch instruction takes 1+1=2 cycles, it is also increased by 2.
Mete