Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Read the time between two lines of code

Hi

I am using app timer in my software and in the timer handler i do multiple things which can take up random amount of time.

I would like to know the time taken from the start of a line of code to the end of the line of code
I could see that I can use app_timer_cnt_get() and convert the ticks to milliseconds , but I cant seem to find the value at which this app_timer_cnt_ge() function will be overflowed or reset to 0.

Is there any other way to achieve the above mentioned specification?

Thanks

  • Hi,

    I found the problem after a bit more testing. What happens is that the TRCENA bit written in cyccnt_enable() gets cleared when the debugger forces the chip out of Debug Interface mode. For instance, after programming of the app is complete. As you might guess, this will disable the cycle counter. Though only if it happens after the cyccnt_enable() function has been run by your app.

    You can do a power cycle, pinreset, etc after programming your test app to confirm this on your side.

    printf I added to monitor the TRCENA status:

    And the expected log output if you test with the same code snippet:

    time = 1000810
    Debug and Trace enabled
    time = 1000667
    Debug and Trace enabled
    time = 1000841
    Debug and Trace enabled
    time = 1000841
    Debug and Trace enabled
    time = 1000841
    Debug and Trace enabled
    time = 1000841

Related