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

Calibrated LFCLK losing 2-3 seconds per minute, doesn't seem to be actually calibrated.

It appears as if the LFCLK is not calibrated to 500PPM accuracy.  I display the time in the system and every 60 seconds it falls 2-3 seconds later relative to the clock on my phone.

Using Softdevice s132 v6.0.0  with SDK 15.0.0. 

Design does not have LF xtal so must use calibrated RC. 

These are the values from sdk_config.h

// <o> NRF_SDH_CLOCK_LF_SRC  - SoftDevice clock source.
 
// <0=> NRF_CLOCK_LF_SRC_RC
// <1=> NRF_CLOCK_LF_SRC_XTAL
// <2=> NRF_CLOCK_LF_SRC_SYNTH

#ifndef NRF_SDH_CLOCK_LF_SRC
#define NRF_SDH_CLOCK_LF_SRC 0
#endif

// <o> NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval.
#ifndef NRF_SDH_CLOCK_LF_RC_CTIV
#define NRF_SDH_CLOCK_LF_RC_CTIV 15
#endif

// <o> NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature.
// <i> How often (in number of calibration intervals) the RC oscillator shall be calibrated
// <i>  if the temperature has not changed.

#ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV
#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 2
#endif

Calling nrf_sdh_enable_request exactly like the example projects.

I enable RTC2 with the LFCLK as the source.

#define SYS_TIME_RTC 2
#define SYS_TIME_RTC_FREQ NRFX_RTC_DEFAULT_CONFIG_FREQUENCY
#define TICKS_PER_SECOND 1024
#define SYS_TIME_PRESCALER (SYS_TIME_RTC_FREQ/TICKS_PER_SECOND)

static const nrfx_rtc_t m_sysTime_rtc = NRFX_RTC_INSTANCE(SYS_TIME_RTC);

static void sysTime_rtc_cb(nrfx_rtc_int_type_t int_type)
{
    uint32_t counter;
    if (int_type == NRFX_RTC_INT_OVERFLOW)
    {
    CRITICAL_REGION_ENTER();
    //increments a counter here...
    CRITICAL_REGION_EXIT();
    }
}

    static const nrfx_rtc_config_t sysTime_rtc_config = {
    .prescaler = SYS_TIME_PRESCALER,
        .reliable = false,
        .tick_latency = 1,
        .interrupt_priority = NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY};
    int err_code;
    err_code = nrfx_rtc_init(&m_sysTime_rtc, &sysTime_rtc_config, sysTime_rtc_cb);

Any suggestions on why the RTC is not ticking at intended 1024 ticks per seconds?

Related