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

nrf51822 rtc with softdevice

Hello,

Is there a demo project that contains RTC function with softdevice. I called the lfclk_config() and rtc_config() function before softdevice initial in main(), but it could not pass through SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL). How can I sovle this issue, am I missing some settting?

void lfclk_config(void)
{
    ret_code_t err_code = nrf_drv_clock_init();
    APP_ERROR_CHECK(err_code);
    nrf_drv_clock_lfclk_request(NULL);
}


void rtc_config(void)
{
    uint32_t err_code;
    //Initialize RTC instance
    nrf_drv_rtc_config_t config = NRF_DRV_RTC_DEFAULT_CONFIG;
    config.prescaler = 4095;
    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,0,COMPARE_COUNTERTIME * 8,true);
    APP_ERROR_CHECK(err_code);
    //Power on RTC instance
    nrf_drv_rtc_enable(&rtc);
}
Parents Reply
  • Hi Vernon. The nRF51 only has two RTCs. The nRF52832 and nRF52840 have 3 RTCs.

    In your case it should be possible to use the RTC driver in the SDK, but if you want to use RTC1 in your own way you cannot use the app_timer library at the same time. Have a look at the RTC example in the SDK. If you use a Softdevice, then make sure to use instance 1 of the RTC with:

    const nrf_drv_rtc_t rtc = NRF_DRV_RTC_INSTANCE(1); /**< Declaring an instance of nrf_drv_rtc for RTC1. */
    
Children
No Data
Related