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

How to enable external clock

Hi,

In our board, GPIO 0, 1 is connected to external oscillator(32.768KHZ).

And I wish to use this oscillator instead of local oscillator.

CLOCK_CONFIG_LF_SRC is already set to 1. But It might need further configuration.

Please let me know how to use external clock.

  • Board: nRF52832
  • nRF5 SDK v16.0.0
  • ESB Example
  • Hi,

    The CLOCK_CONFIG_LF_SRC setting will only have an effect if you use the SDK clock driver, but it doesn't look like the ESB example use this driver. Another option to using the driver is to start the the crystal oscillator directly as shown in the code snippet below.

    void clocks_start( void )
    {
        // Start HFCLK and wait for it to start.
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_HFCLKSTART = 1;
        while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);
    
        // Start LFXO and wait for it to start
        NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos;
        NRF_CLOCK->TASKS_LFCLKSTART = 1;
        while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);
    }

Related