This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640R2F: Timer to measure the execution time of a function

Part Number: CC2640R2F

Hello,

Is there any timer that can used to measure the execution time of a function? I have Util_constructClock() but i expires after certain period. It does not really tell about how much time passed as it takes a fix period as argument and expires once the period is reached.

Is there any timer that starts and at some point it tells that how much time is passed?

I will be waiting for your kind reply.

 

  • Mabbas,

    There are a couple of ways you can do this.

    You can set the clock period to desired time resolution t (ie 100 ms). Then at beginning of function you can start the clock and at the end you can stop the clock. In the clock callback function, you can increment a global variable. Then you will know how many multiples of t have passed within the function.

    You can also use the timer files located in <sdk>/source/ti/drivers/timer. It has an edge_time mode that you may find useful.

    Regards,
    Toby
  • That's an idea.

    Another one is to use the Timestamp module (in the kernel documentation). Take a timestamp before and after your API and then calculate your delta.
  • Hi Tom Kopriva,

    Thanks for your suggestion. I using IAR workbench 7.80.3 . Do Timestamp also work in IAR? I don,t understand if Timestamp_get32() return time in millisecond or microsecond?

    Can you tell me what is the unit of value returned by Timestamp_get32()?

    I will be really thankful to you.

  • Mabbas,

    Units of Timestamp_get32() is how many clock ticks have passed.

    You can determine the frequency (in Hz) of the clock by using:
    Types_FreqHz freq;
    Timestamp_getFreq( &freq );

    freq.hi and freq.lo are the high 32 bits and low 32 bits of the clock frequency.

    Regards,
    Toby

    PS: be sure to #include <xdc/runtime/Types.h>