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

Can I add HFCLKSRC in nrf51.h?

Hello,

I am using the custom board. There is 32MHz external oscillator. So, I implemented like below source code for clock control.

NRF_CLOCK->LFCLKSRC            = (CLOCK_HFCLKSTAT_SRC_Xtal << CLOCK_HFCLKSTAT_SRC_Pos);
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK->TASKS_HFCLKSTART    = 1;
NRF_CLOCK->XTALFREQ  = CLOCK_XTALFREQ_XTALFREQ_32MHz; 

But, I think that I need NRF_CLOCK->HFCLKSRC for external oscillator. In your nrf51 series reference manual, HFCLKSRC is referred. But, there is not any source code for HFCLKSRC in nrf51.h and there is not any register information for HFCLKSRC in reference manual.

Could you let me know the guide for it?

Thanks.

  • HFCLKSRC isn't a register, it's just an internal designation, there is only one place to connect the HF clock source and that's pins XC1 and XC2. You can use a 16 or 32MHz crystal or, according to the manual, a 16MHz external source, here's the relevant piece

    The HFCLK crystal oscillators utilize amplitude regulated architecture to achieve low current consumption and fast start-up. The HFCLK crystal oscillators are also designed to work with one of the following alternative external sources:

    • A 16 MHz rail-to-rail clock signal applied to the XC1 pin. The XC2 pin shall then be left unconnected.
    • A 16 MHz low swing clock signal applied to the XC1 pin. The XC2 pin shall then be left unconnected.

    So external source is specified by leaving XC2 unconnected.

    It says nothing there about a 32MHz external reference. The table 11 in chapter 3.6 of the nrf51822 product spec also says you have a choice of 16/32MHz crystal or 16MHz external, no option for 32MHz external is listed there.

    I would expect if 32MHz external was available, it would work by connecting the external source to XC1, leaving XC2 unconnected and specifying 32MHz as you have done. If that doesn't work, it's probably because 32MHz external clock is not an available option.

Related