I am maintaining some code in C for STM8 using IAR Embedded. what is the way to measure execution time between one part of the code and another? (Take into account that if possible I don't want to stop the execution of the code (a la breakpoint) or write to the console (since I found that this affects heavily the timing of the program).
I ve found something like this Techniques for measuring the elapsed time
but this is usually for ARM processors so many of the methods don't apply to my setting. I am thinking something like Technique #3 might be applicable...
Concretely I am asking if I can do something like that technique
unsigned int cnt1 = 0;
unsigned int cnt2 = 0;
cnt1 = TIM3->CNT;
func();
cnt2 = TIM3->CNT;
printf("cnt1:%u cnt2:%u diff:%u \n",cnt1,cnt2,cnt2-cnt1);
for this microcontroller
Any help greatly appreciated