how can I time my code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-29 3:10 AM
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?
- Labels:
-
STM32CubeIDE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-29 4:48 AM
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 seconds
As modifying your code you can see each time the needed time in the console and compare the results.
I hope this help!
-Imen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-29 4:55 AM
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​
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-29 8:28 AM
Run time, not compile time..
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-29 8:42 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-29 11:25 AM
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
