9 years, 11 months ago.

How can I read the cycle counter on my Nucleo stm32f401re board.

I'd like to measure how many cycles are required for a specific operation. Is there a free running cycle counter available?

1 Answer

9 years, 11 months ago.

There is no direct cycles counter. You can use one of the 32 bit timer. They can be clocked internal divided by 1 to use the same frequency as the cpu. The timers are complex to setup. Import the mbed-src lib. You can find the documented cmsis timer files in stm32f4xx_hal_tim.c Also consult the RM0368 Reference manual.

Accepted Answer

Thanks Peter. I found TIM5 being used in the us_ticker.c module and have been reading that value to get a granularity of microseconds which seems close enough.

posted by Chris LeBlanc 02 Oct 2014