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

External Clocks

I'm using v14 of the SDK and I cannot for the life of me get either the external 32MHz or 32.768kHz clocks working.

How is this possible using the SDK?

Parents
  • Hi,

     

    Most examples uses the external LFCLK by default. The external HFCLK is started on-demand (automatically by the softdevice) for power consumption reasons.

    Use this code snippet to test your clock sources (add them to the blinky example for instance):

    NRF_CLOCK->TASKS_HFCLKSTART = 1;
    while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);
        
    NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos;
    NRF_CLOCK->TASKS_LFCLKSTART = 1;
    while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);

    If your code hangs in one of the while-loops, then there's an external problem with your clock source (loading caps incorrect, soldering issue, or similar)

    Note: if adding this to a SoftDevice example, be sure to run this _prior to the softdevice enable_

     

    Cheers,

    Håkon

  • Thanks for your code sample. I will try this shortly.

    Is there any benefit in using the external 32MHz and 32.768kHz crystals over using the internal ones?

    Obviously a reduction in BOM component cost is very beneficial.

Reply Children
Related