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

SDK17 timestamp issue: clean time auto

Hi,

  I use the timestamp log in SDK17,  and I find the time will auto clean at about 1min6-7sec.

   

Below is the code init the log.

/******************************************************************/

#define USE_CYCCNT_TIMESTAMP_FOR_LOG  1   // 0


uint32_t cyccnt_get(void)
{
return DWT->CYCCNT;
}


void timerstamp_log_init(void)
{
ret_code_t ret;
if (USE_CYCCNT_TIMESTAMP_FOR_LOG)
{
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
DWT->CYCCNT = 0;
APP_ERROR_CHECK(NRF_LOG_INIT(cyccnt_get, 64000000));
}
else
{
APP_ERROR_CHECK(NRF_LOG_INIT(app_timer_cnt_get));
}
NRF_LOG_DEFAULT_BACKENDS_INIT();
ret = nrf_drv_clock_init();
APP_ERROR_CHECK(ret);
nrf_drv_clock_lfclk_request(NULL);
}

/*********************************************************/

What's the reason of it?  How to fix it?

Could you please give a help?

Thank you very much!

Parents
  • Hi,

    The CYCCNT seems to overflow after 2^32 / 64MHz = 67,108seconds. You likely will need to use app_timer here by:

    USE_CYCCNT_TIMESTAMP_FOR_LOG  0

    Best regards,
    Kenneth

  • Dear Kenneth,

        Thanks for your reply.  Yes, if set USE_CYCCNT_TIMESTAMP_FOR_LOG = 0 ,the time is OK at the beginning.

        Then,another issue comes out.  I use my phone send '0' and '1' to nRF52 very slowly after connect, you can see them in below.But the time is stopped, no matter how many times I send.

         After that, I disconnect nRF52, and re-connect it. The time runs(it runs ,but it is not right, the time runs very slowly).

        Then, the time stopped again :  I use my phone send '0' and '1' to nRF52 very slowly,  and the time is not change.

     

    What is the reason of it? How can we fix it?

    Thank you very much!

    Best regards,

    Jack Wang

Reply
  • Dear Kenneth,

        Thanks for your reply.  Yes, if set USE_CYCCNT_TIMESTAMP_FOR_LOG = 0 ,the time is OK at the beginning.

        Then,another issue comes out.  I use my phone send '0' and '1' to nRF52 very slowly after connect, you can see them in below.But the time is stopped, no matter how many times I send.

         After that, I disconnect nRF52, and re-connect it. The time runs(it runs ,but it is not right, the time runs very slowly).

        Then, the time stopped again :  I use my phone send '0' and '1' to nRF52 very slowly,  and the time is not change.

     

    What is the reason of it? How can we fix it?

    Thank you very much!

    Best regards,

    Jack Wang

Children
Related