Skip to main content
Explorer II
February 1, 2024
Question

using DWT CYCCNT under debugger

  • February 1, 2024
  • 1 reply
  • 1330 views

 

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.

    This topic has been closed for replies.

    1 reply

    ST Employee
    February 1, 2024

    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

    meteAuthor
    Explorer II
    February 1, 2024

    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