LFCLK External Xtal and Soft Device

I am attempting to enable the external LFCLK. I want the clock to swing rail to rail.  I have the following code in place.

    /* Start low frequency crystal oscillator for app_timer(used by bsp)*/
    NRF_CLOCK->LFCLKSRC            = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
    NRF_CLOCK->LFCLKSRC            = (CLOCK_LFCLKSRC_EXTERNAL_Enabled  << CLOCK_LFCLKSRC_EXTERNAL_Pos);
    NRF_CLOCK->LFCLKSRC            = (CLOCK_LFCLKSRC_BYPASS_Enabled << CLOCK_LFCLKSRC_BYPASS_Pos);
    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_LFCLKSTART    = 1;

    while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
    {
        // Do nothing.
    }
    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;


I am using the s140 v 7.2 soft device and the nRF5_SDK_17.0.2_d674dde version of the sdk.

Is there some additional configuration step I'm missing?


Parents Reply Children
  • stevebedford said:
    Also, I've read in other discussion threads that if the 32kHz signal is not configured correctly that the soft device will not advertise.  I am seeing the device advertising when scanning; does that suggest that the clock actually is enabled correctly?

    This is correct if the Softdevice is configured to use the LFCLK. Have you configured a clock source for the Softdevice in your application?

    Regards,
    Sigurd Hellesvik

Related