This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nRF52832 LFCLK external signal and soft device

Hello,

I try to set up an external signal for the LFCLK on a nrf52832. From this question:

  • I know the nrf52832 can do this (signal on XL1 pin, XL2 grounded).
  • I know I must set the bits "bypass" and "external clock" in LFCLKSRC register.

But I don't know how to set these bits through the SDK functions, with a running soft device.

  • Defines like CLOCK_LFCLKSRC_BYPASS_xxx and CLOCK_LFCLKSRC_EXTERNAL_xxx dont exist in the SDK 11.0.0.
  • The function softdevice_handler_init() (through SOFTDEVICE_HANDLER_APPSH_INIT()) hasn't the required parameter in the nrf_clock_lf_cfg_t structure.
  • The function softdevice_handler_init() forces LFCLK configuration and the LFCLKSRC register can't be set after the soft device initialization.

Can someone give me a valid code example?

Thanks !

Parents
  • Hi,

    As the post you linked to says you start the clock the same way you start any LF crystal, ie. you call

    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);
    

    Substitute NRF_CLOCK_LFCLKSRC_XTAL_20_PPM with the accuracy of the external clock source you are using.

    Since the SoftDevice uses the LF clock for synchronization is must be left on at all times while the SoftDevice is running.

    Best regards,

    Øyvind

Reply
  • Hi,

    As the post you linked to says you start the clock the same way you start any LF crystal, ie. you call

    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);
    

    Substitute NRF_CLOCK_LFCLKSRC_XTAL_20_PPM with the accuracy of the external clock source you are using.

    Since the SoftDevice uses the LF clock for synchronization is must be left on at all times while the SoftDevice is running.

    Best regards,

    Øyvind

Children
  • Thanks for your quick answer. The method you describe was ok for an old SDK, now softdevice_handler_init (and SOFTDEVICE_HANDLER_INIT and SOFTDEVICE_HANDLER_APPSH_INIT) takes a nrf_clock_lf_cfg_t structure as the first parameter. With the SDK 111.0.0, I 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	\
    }
    nrf_clock_lf_cfg_t clockLfCfg = NRF_CLOCK_LFCLKSRC;
    SOFTDEVICE_HANDLER_APPSH_INIT(&clockLfCfg, true);
    

    But I need to set the "bypass" and "external clock" bits in LFCLKSRC register and nrf_clock_lf_cfg_t doesn't help me to do that...

    Do you have any example code to do that?

    -> See my own answer

Related