manually start HFXO?

dear members,

how can I manually start hfxo from code?

thanks

  • Hi,

    This depends a bit on which SDK you are using, and also which components from that SDK you are using.

    If for instance you are using the nRF5 SDK with a SoftDevice, then you need to either use the SoftDevice API directly and call sd_clock_hfclk_request(). Alternatively, you can use the clock driver, which will do this for you. It will also handle multiple users so that if the clock is requested several time it will only be stopped after it has been released the same amount of times. That means that if you use other SDK library that use the clock driver, you must also use the clock driver.

    If you do not use a SoftDevice, you can also use the clock driver, as it handles both cases. Alternatively, you can simply start the clock directly like this:

        // Start 64 MHz crystal oscillator.
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_HFCLKSTART    = 1;
    
        // Wait for the external oscillator to start up.
        while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
        {
            // Do nothing.
        }

    If you are using the nRF Connect SDK, you can start the HFXO as demonstrated by clock_init() here.

Related