Know the duration of execution of a function

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
alma_284856
Level 3
Level 3
First like received

 Hi everyone,

   

I have a function which is called in an interruption. I would like define the call of my interruption according to the duration of execution of my function.

   

Normaly to know simply the duration of execution I set a pin at the begining and clear the pin at the end of the function. I look on a oscilloscope the duration.

   

But at home I haven't osciloscope. Is there a simply method to know the duration? I have  a UART to send data 

   

 

   

 

   

 

   

Thank you

0 Likes
3 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

You could place a timer, start it before the f() call, then

   

stop and read it after f() return would be one way.

   

 

   

A more exact method is count the code cycles in the ASM listing, .LST file

   

in the workspace result tab.

   

 

   

Regards, Dana.

0 Likes
alma_284856
Level 3
Level 3
First like received

 Okay thanks but I don't understand something,

   

if I put a clock of 24MHZ on the timer with a period of 256 (10,667µS) , when I stop the timer in my function,how can I have the time? I will get the counter value of the timer

   

 

   

thank you

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

The timer is a down counter starting at its period value.

   

When started it starts counting down, and when you stop

   

it, the value (period - counter value)  X input clock period = time

   

of event.

   

 

   

You could use an up counter, and accomplish the same

   

thing ithout the subtract math.

   

 

   

Regards, Dana.

0 Likes