This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Clarification about nrf-calaendar example

Hello,

I'm trying to integrate the nrf Calendar example here with Current Time Service client implementation on a nRF52840 DK.

I'm trying to understand the logic of the Calendar example.

Can someone explain the nrf_cal_set_callback function in nrf_calendar.c and what it does?

Thanks,

Parents Reply Children
  • Hi

    It is a simple linear correction that is intended to detect if the internal clock is running consistently too slow or too fast. 

    When you adjust the time in the calender library it will detect if the internal clock ran faster or slower than the 'real' time provided through the nrf_cal_set_time(..) function, compared to the last time nrf_cal_set_time(..) was called. 

    For this to work properly it assumes that clock inaccuracies are consistent (don't vary over time), that you don't call nrf_cal_set_time(..) very often, and that you don't call nrf_cal_set_time(..) with an outdated time stamp. 

    It's worth mentioning that this function hasn't been tested very extensively either, so please use it at your own risk ;)

    If you need good clock accuracy I would strongly recommend using an external LF crystal rather than relying on the calibration. 

    Best regards
    Torbjørn

Related