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

How to config NRF51822 custom board Xtal Freq to 32MHz using nrf51dk

Hi, I'm trying to program my custom board which has external 32MHz Xtal oscillator using nRF51 DK.

 I have connected the custom board and the DK well and by using nrfgo I could succesfully upload the code to the custom board.

I uploaded the SDK12.3.0/ble_app_beacon/pca10028/s130, with softdevice s130 ver2.0.1.

Because my custom board uses 32MHz Xtal oscill. I want to change the default Xtal oscillator frequency 16MHz to 32MHz but failed.

I have found some QnAs related to the question such as,

https://devzone.nordicsemi.com/f/nordic-q-a/6394/use-external-32mhz-crystal

and I followed the step but couldn't make it. It says that I should change system.nrf.51.c and change UICR register and  put the code

NRF_CLOCK->XTALFREQ = 0xFFFFFF00; 

I was able to find system nrf51.c but didn't understand about the other solutions.

Where exactly should I write down that code? Is it still available at SDK12.3.0 example?

It seems not that hard but I'm spending a lot of time solving this problem.

Thanks you.
Parents
  • Hi,

    Is not important when you update the frequency setting as long as it done before the crystal is started by the app. You can update the register in main so that you don't have to modify the startup files:

    int main(void)
    {
        // Set the external high frequency clock source to 32 MHz
        NRF_CLOCK->XTALFREQ = 0xFFFFFF00;
    ...
    }

    The other option is to change the reset value of NRF_CLOCK->XTALFREQ to 32 MHz. Reset value is defined by NRF_UICR->XTALFREQ


Reply
  • Hi,

    Is not important when you update the frequency setting as long as it done before the crystal is started by the app. You can update the register in main so that you don't have to modify the startup files:

    int main(void)
    {
        // Set the external high frequency clock source to 32 MHz
        NRF_CLOCK->XTALFREQ = 0xFFFFFF00;
    ...
    }

    The other option is to change the reset value of NRF_CLOCK->XTALFREQ to 32 MHz. Reset value is defined by NRF_UICR->XTALFREQ


Children
Related