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

Can't start LFCLK when softdevice is not present

Hi.

I am trying to get the RTC started, and I've followed the rtc example in the NRF51_SDK.

But things go wrong when I call:

ret_code_t err_code = nrf_drv_clock_init(NULL);
APP_ERROR_CHECK(err_code);

I get the errer code: 2, meaning NRF_ERROR_SOFTDEVICE_NOT_ENABLED. And that is exactly right, the softdevice is not enabled, because I want to be able to debug for the moment?

(btw. will it ever be possible to debug while using the softdevice, it is getting pretty annoying, not to be able to debug :) )

  • Well, I had the same intentions since I want to precisely determine when the SD is running. My case is simpler since I use ANT. SDK version is 10.

    But here is what I did:

    In the components/drivers_nrf/clock/nrf_drv_clock.c I added these controls at the beginning and at the end of the file. This file maintains the behavior when the SD is either enabled or disabled. Or it can easily changed back.

    #ifdef SOFTDEVICE_PRESENT
    #define RESTORE_SOFTDEVICE 1
    #undef SOFTDEVICE_PRESENT
    #endif
    
    #if RESTORE_SOFTDEVICE
    #define SOFTDEVICE_PRESENT
    #undef ENABLE_SOFTDEVICE
    #endif
    

    In the examples/../config/nrf_drv_config.h I changed CLOCK_ENABLED to 1 and defined the calibration interval for the clock driver.

    #define CLOCK_ENABLED 1
     
    #if (CLOCK_ENABLED == 1)
    #define CLOCK_CONFIG_XTAL_FREQ          NRF_CLOCK_XTALFREQ_Default
    #define CLOCK_CONFIG_LF_SRC             NRF_CLOCK_LF_SRC_RC
    #define CLOCK_CONFIG_IRQ_PRIORITY       APP_IRQ_PRIORITY_LOW
    #define CLOCK_CONFIG_LF_RC_CAL_INTERVAL	RC_16000MS_CALIBRATION_INTERVAL
    #endif
    

    As a result I can call nrf_drv_clk_init() and nrf_drv_clock_lfclk_request() without softdevice being inited. If I want to enable the SoftDevice I trigger corresponding release() and uninit() calls before initing the radio.

Related