2022-03-05 08:33 PM
Hi everyone,
I am preparing a course for university and I plan to use G071RB NUCLEO board. I wish to show floating point calculation without FPU is pretty slow, so is there a way to show cpu cycle count feature from debug?
Thank you!
2022-03-05 09:01 PM
Get a timer running at core frequency as freerun, read the timer value as a timestamp. If you have 32 bit hw timer, use it. The other way to check performance is to toggle a gpio. Do know that emulated float or double sw libraries are not all equals, maybe compiler and compiler options dependent. Have a look at Segger math library to start digging this topic.
2022-03-06 06:19 AM
From debug?
Probably not directly.
You could use a TIM to count time.
You might be able to use the SYSTICK counter, it's a 24-bit down-counter, I think you could use that in a maximal mode, and do some 24-bit unsigned truncated math.
Typically for illustrative purposes you'd build a benchmarking frame-work that could test subroutines/sequences over N iterations, and use a timer. If you do enough iterations you could use micro-second or milli-second time counts to quantify the speed of different algorithms or operations.
STM32G071 has one 32-bit counter, could clock that at CPU frequency, or 1 MHz, and delta the value of TIMx->CNT either side of the test code.
2022-03-06 12:48 PM
Thank you all for your reply. I should have mention that I have a logic analyzer, and I can toggle a pin and time it. but I was hoping there is a more "elegant" way to do the same from the debugging view. I guess only SWV interface could possible to offer this feature.
Again, thank you all for your suggestions, and I will dig in more.