cancel
Showing results for 
Search instead for 
Did you mean: 

using DWT CYCCNT under debugger

mete
Senior

 

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.

2 REPLIES 2
Pierre_Paris
ST Employee

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.

Hi @Pierre_Paris 

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