cancel
Showing results for 
Search instead for 
Did you mean: 

how can I time my code?

deep_rune
Associate III

I am using cubeIDE and I'd like to know how I can time my code, to see how long individual sections take to run and troubleshoot timing issues. How can I do this?

5 REPLIES 5
Imen Ezzine
ST Employee

Hi PGoul,

I would say you can find interesting informations in the log section of the cubeIDE (console).

See below an example where the needed time for the project build took around 3 seconds0693W000003BcFwQAK.png

As modifying your code you can see each time the needed time in the console and compare the results.

I hope this help!

-Imen

Use a free running maximal TIM, perhaps a 32-bit one clocking at 1 MHz, read values entering / exiting a code section. Could clock at higher speed for more precision.

Check also DWT_CYCCNT for core cycle count​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Run time, not compile time..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal

If you have timing issues, first try to view your running code in your mind and try to find out logically.

When needed, if you have some spare pins toggles some GPIO on oscilloscope to view what's going on.

Having a critical timing gets tricky. Are you talking about max interrupt latency and duration/priority issue here?

prain
Senior III

Use DWT cycle counters. It can show you the number of cpu cycles between two successive break points. you should first enable it in your init phase. Cycle counters are available in SFR register view in cubeide