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

Equivalent low-frequency clock source in nRF5 SDK 11.0.0?

Hi,

I've started using the nRF5 11.0.0 (89a8197) SDK on a board that does not include an external low-frequency CLK source.

When using the nRF52 0.9.2 SDK, we were recommended to use NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_4000MS_CALIBRATION as our LF CLK source.

What would be the recommendation for our LF CLK source definition now?

I can see nrf_clock_lf_cfg_t and NRF_CLOCK_LFCLKSRC as defined for each of the Development Kit boards (I'm using the pca10040 GCC Makefile on our custom board.)

Is the equivalent structure something like:

{ .source        = NRF_CLOCK_LF_SRC_RC,            \
  .rc_ctiv       = 16,                             \
  .rc_temp_ctiv  = 2,                              \
  .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM}

Thanks, Max

  • Hi Max

    The settings that you have proposed are the recommended settings when using internal RC low frequency 32kHz clock with the nRF52832. The recommendation and explanation on those parameters are described in the softdevice manager (nrf_sdm.h) in nRF5 SDK 11.0.0. I copy it here for convenience:

    /**@brief Type representing lfclk oscillator source. */
    typedef struct
    {
    	uint8_t source;        /**< LF oscillator clock source, see @ref NRF_CLOCK_LF_SRC. */
    	uint8_t rc_ctiv;      /**< Only for NRF_CLOCK_LF_SRC_RC: Calibration timer interval in 1/4 second
    															units (nRF51: 1-64, nRF52: 1-32).
    															@note To avoid excessive clock drift, 0.5 degrees Celsius is the
    																		maximum temperature change allowed in one calibration timer
    																		interval. The interval should be selected to ensure this.
    
    															@note Must be 0 if source is not NRF_CLOCK_LF_SRC_RC.  */
    	uint8_t rc_temp_ctiv; /**<  Only for NRF_CLOCK_LF_SRC_RC: How often (in number of calibration
    															intervals) the RC oscillator shall be calibrated if the temperature
    															hasn't changed.
    																	0: Always calibrate even if the temperature hasn't changed.
    																	1: Only calibrate if the temperature has changed (nRF51 only).
    																	2-33: Check the temperature and only calibrate if it has changed,
    																				however calibration will take place every rc_temp_ctiv
    																				intervals in any case.
    
    															@note Must be 0 if source is not NRF_CLOCK_LF_SRC_RC.
    
    															@note For nRF52, the application must ensure calibration at least once
    																		every 8 seconds to ensure +/-250ppm clock stability. The
    																		recommended configuration for NRF_CLOCK_LF_SRC_RC on nRF52 is
    																		rc_ctiv=16 and rc_temp_ctiv=2. This will ensure calibration at
    																		least once every 8 seconds and for temperature changes of 0.5
    																		degrees Celsius every 4 seconds. See the Product Specification
    																		for the nRF52 device being used for more information.*/
    	uint8_t xtal_accuracy; /**< External crystal clock accuracy used in the LL to compute timing windows.
    
    															@note For the NRF_CLOCK_LF_SRC_RC clock source this parameter is ignored. */
    } nrf_clock_lf_cfg_t;
    
  • @stefanbirnir

    i tried to change the clock to synth but it doesnt build.

    NRF_CLOCK_LFCLKSRC      {.source        = NRF_CLOCK_LF_SRC_Synth,            \
                                     .rc_ctiv       = 0,                                \
                                     .rc_temp_ctiv  = 0,                                \
                                     .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM}
    

    it works only for the two clocks NRF_CLOCK_LF_SRC_RC and NRF_CLOCK_LF_SRC_Xtal

    is synth not supported ?

    NRF_CLOCK_LF_SRC_Synth' undeclared (first use in this function)
     #define NRF_CLOCK_LFCLKSRC      {.source        = NRF_CLOCK_LF_SRC_Synth,            \
                                                       ^
    /home/brook/Desktop/nordicSDK11/examples/smartplane/SmartPlane/main.c:322:39: note: in expansion of macro 'NRF_CLOCK_LFCLKSRC'
         nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;
                                           ^
    /home/brook/Desktop/nordicSDK11/examples/bsp/pca10028.h:146:51: note: each undeclared identifier is reported only once for each function it appears in
     #define NRF_CLOCK_LFCLKSRC      {.source        = NRF_CLOCK_LF_SRC_Synth,            \
                                                       ^
    /home/brook/Desktop/nordicSDK11/examples/smartplane/SmartPlane/main.c:322:39: note: in expansion of macro 'NRF_CLOCK_LFCLKSRC'
         nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;
    
  • Try to use

    #define NRF_CLOCK_LFCLKSRC      {.source       = NRF_CLOCK_LF_SRC_SYNTH,            \
    							    .rc_ctiv       = 0,                                \
    							    .rc_temp_ctiv  = 0,                                \
    							    .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM}
    
Related