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

lf clock configuration with softdevice

Hello,

In sdk 14.2 configuration of LF clock with softdevice are in 2 header files (pca100xx.h and sdk_config.h)

pca10040.h

// Low frequency clock source to be used by the SoftDevice
#define NRF_CLOCK_LFCLKSRC      {.source       = NRF_CLOCK_LF_SRC_RC,      \
                                 .rc_ctiv      = 16,                          \
                                 .rc_temp_ctiv = 2,                          \
                                 .accuracy     = NRF_CLOCK_LF_XTAL_ACCURACY_250_PPM}

and in sdk_config.h

//==========================================================

// <h> Clock - SoftDevice clock configuration

//==========================================================
// <o> NRF_SDH_CLOCK_LF_SRC  - SoftDevice clock source.

// <0=> NRF_CLOCK_LF_SRC_RC
// <1=> NRF_CLOCK_LF_SRC_XTAL
// <2=> NRF_CLOCK_LF_SRC_SYNTH

#ifndef NRF_SDH_CLOCK_LF_SRC
#define NRF_SDH_CLOCK_LF_SRC 0
#endif

// <o> NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval.
#ifndef NRF_SDH_CLOCK_LF_RC_CTIV
#define NRF_SDH_CLOCK_LF_RC_CTIV 16
#endif

// <o> NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature.
// <i> How often (in number of calibration intervals) the RC oscillator shall be calibrated
// <i>  if the temperature has not changed.

#ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV
#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 2
#endif

Which one is really used ?

Thanks

  • The NRF_SDH_xx #defines in sdk_config.h are used by the Softdevice Handler (nrf_sdh.c). You can tell the softdevice handler which clock source to use with NRF_SDH_CLOCK_LF_SRC, calibration interval with NRF_SDH_CLOCK_LF_RC_CTIV and so on. If you are not using the softdevice handler you can use the macro in pca10040.h to set all values of the nrf_clock_lf_cfg_t to a default value:

    nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;

    You can still change the individual fields, eg:

    clock_lf_cfg.source = NRF_CLOCK_LF_SRC_XTAL;

    clock_lf_cfg.accuracy = NRF_CLOCK_LF_ACCURACY_20_PPM;

Related