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

lfclk, rtc issue on SDK13

I am trying to set up RTC2 by following an example github.com/.../saadc_low_power I ported it to my project which is running a softdevice on nRF52. It works perfectly fine on SDK11 but has problems on SDK13.0 / 13.1. Seems like nrf_drv_clock_init() or nrf_drv_rtc_init() has conflict with the BLE stack. Any idea what has changed from SDK11 to SDK13?

Parents
  • Here I ported it to the ble_app_hts_c project in Nordic example codes. lfclk_config() and rtc_config() are the two functions added. It is going to crash in ble_stack_init() in the following order. If I put the two clock functions after ble_stack_init(), they failed. Looks the three functions are fighting each other. It works fine in SDK11 though.

    int main(void)
    {
    ...
    lfclk_config();                                  //Configure low frequency 32kHz clock
    rtc_config();                                    //Configure RTC. 
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);
    buttons_leds_init(&erase_bonds);
    nrf_log_init();
    APPL_LOG("Temperature collector example\r\n");
    ble_stack_init();
    ...
    }
    static void lfclk_config(void)
    {
        ret_code_t err_code = nrf_drv_clock_init();                        //Initialize the clock source specified in the nrf_drv_config.h file, i.e. the CLOCK_CONFIG_LF_SRC constant
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_clock_lfclk_request(NULL);
    }
    
    static void rtc_config(void)
    {
        uint32_t err_code;
    
        //Initialize RTC instance
        err_code = nrf_drv_rtc_init(&rtc, NULL, rtc_handler);              //Initialize the RTC with callback function rtc_handler. The rtc_handler must be implemented in this applicaiton. Passing NULL here for RTC configuration means that configuration will be taken from the nrf_drv_config.h file.
        APP_ERROR_CHECK(err_code);
    
        err_code = nrf_drv_rtc_cc_set(&rtc,0,RTC_CC_VALUE,true);           //Set RTC compare value to trigger interrupt. Configure the interrupt frequency by adjust RTC_CC_VALUE and RTC2_CONFIG_FREQUENCY constant in the nrf_drv_config.h file
        APP_ERROR_CHECK(err_code);
    
        //Power on RTC instance
        nrf_drv_rtc_enable(&rtc);                                          //Enable RTC
    }
    
Reply
  • Here I ported it to the ble_app_hts_c project in Nordic example codes. lfclk_config() and rtc_config() are the two functions added. It is going to crash in ble_stack_init() in the following order. If I put the two clock functions after ble_stack_init(), they failed. Looks the three functions are fighting each other. It works fine in SDK11 though.

    int main(void)
    {
    ...
    lfclk_config();                                  //Configure low frequency 32kHz clock
    rtc_config();                                    //Configure RTC. 
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);
    buttons_leds_init(&erase_bonds);
    nrf_log_init();
    APPL_LOG("Temperature collector example\r\n");
    ble_stack_init();
    ...
    }
    static void lfclk_config(void)
    {
        ret_code_t err_code = nrf_drv_clock_init();                        //Initialize the clock source specified in the nrf_drv_config.h file, i.e. the CLOCK_CONFIG_LF_SRC constant
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_clock_lfclk_request(NULL);
    }
    
    static void rtc_config(void)
    {
        uint32_t err_code;
    
        //Initialize RTC instance
        err_code = nrf_drv_rtc_init(&rtc, NULL, rtc_handler);              //Initialize the RTC with callback function rtc_handler. The rtc_handler must be implemented in this applicaiton. Passing NULL here for RTC configuration means that configuration will be taken from the nrf_drv_config.h file.
        APP_ERROR_CHECK(err_code);
    
        err_code = nrf_drv_rtc_cc_set(&rtc,0,RTC_CC_VALUE,true);           //Set RTC compare value to trigger interrupt. Configure the interrupt frequency by adjust RTC_CC_VALUE and RTC2_CONFIG_FREQUENCY constant in the nrf_drv_config.h file
        APP_ERROR_CHECK(err_code);
    
        //Power on RTC instance
        nrf_drv_rtc_enable(&rtc);                                          //Enable RTC
    }
    
Children
No Data
Related