Is there any builtin feature available in Keil uVision to measure execution time of a function or task for STM32F103?
2 Answers
Welcome to EE StackExchange.
I'm not familiar with Keil tools, but a quick internet search yields this, so the answer is Yes.
A practical approach would be to use an GPIO and an oscilloscope.
Set the GPIO high when entering you function/task and low when exiting.
Connect the scope probe to the GPIO and you can measure the execution time and frequency of your function/task.

- 2,024
- 14
- 19
-
If i have spare timer in the MCU then how can i use it to find execution time of a function? – alt-rose May 29 '19 at 08:44
-
2@alt-rose [There is a built-in timer that counts clock cycles](https://stackoverflow.com/questions/42246125/how-to-get-time-intervals-on-stm32) – followed Monica to Codidact May 29 '19 at 09:00
Sort of...
If you have the TRACESWO pin connected, you can stream limited realtime debug data to keil. One of the things it can include here is the time spent in each ISR.
Also, it is most likely possible to measure performance of threads when using Keils own operating system RTX.
If you own the ULINK Pro, and have the parallel ETM interface wired up, you have a lot more realtime instruction tracing options.
Basically, without TRACESWO you'd have to look into the performance analyzer options of the RTOS in question, or roll your own. Using either a spare timer, or the DWT_CYCCNT.
But an array of GPIO into a logic analyzer works as well.

- 21,976
- 36
- 73