This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Why is the cycle count for running the same instruction multiple times not linearly increasing on the STM32F4?

Hi everyone,

I am trying to understand why the cycle count is not linearly increasing if I run the same instruction x times on the STM32F405RGT6.

When playing around with the STM32F4 to get a better understanding of instructions to cycles counts, I stumbled across this problem. From the documentation I know that a NOP and an ADD operation both should take one cycle. Therefore I would expect x NOPs to take x cycle and the same for ADD. What I found is somewhat different.

To produce these results I wrote a quick script that creates 30 assembly code functions. I can read the cycle count from the memory address 0xE0001004 on the STM32F405RGT6. I can also input any values into r3 and r4 for the ADD operation and check the result in r5. In r6 I get the number of cycles my instructions took. I checked the final elf file with objdump to verify that no operations were removed/rearranged/altered by the compiler.

Can someone please explain why the cycle count is increasing non-linearly? Thanks in advance for any insights.

0