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

nRF52832 RTC inaccuracy LF CLK?

Hi. We are using RTC2 in our application to trigger an event at 256Hz. We also have a compare running to trigger a compare event at 32Hz.

I have found that over an hour, event will have been running slowly about 98% of the rate it should be. Below is the code to setup the RTC.

How do I check that our external LF clk (crystal) is running and not the internal RC clock? This could be causing the problem / inaccuracy.

We are using the softdevice, but may be using the internal oscillator instead of the external one.

Thanks

/** @brief Function initialization and configuration of RTC driver instance.
 */
static void rtc_config(void)
{
    uint32_t err_code;

    //Initialize RTC instance
    nrf_drv_rtc_config_t config = NRF_DRV_RTC_DEFAULT_CONFIG;
    config.prescaler = 127;  //1023 = 32 Hz, 127 = 256 Hz
    config.interrupt_priority = 7;
    err_code = nrf_drv_rtc_init(&rtc, &config, rtc_handler);
    APP_ERROR_CHECK(err_code);

    //Enable tick event & interrupt
    nrf_drv_rtc_tick_enable(&rtc,true);

    //Set compare channel to trigger interrupt after COMPARE_COUNTERTIME seconds
    err_code = nrf_drv_rtc_cc_set(&rtc,2,8,true); //x8 = 32Hz
    APP_ERROR_CHECK(err_code);

    //Power on RTC instance
    nrf_drv_rtc_enable(&rtc);
}

Parents Reply Children
No Data
Related