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?
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?
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
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.
32M crystal is required for the radio to work. This one you cannot get around if you want to use the radio.
32k can be sourced from either an external 32k crystal, or using the internal 32k RC oscillator. Using the RC oscillator will give a penalty on power consumption (you need to calibrate regularly), but reduce BOM cost.
This is quite strange because I have had the SparkFun nRF52832 board running (using Arduino BLEPeripheral code) and when checking the 32M clock, there was barely any output.
If you scope XC1/XC2, you change the load (impedance), thus reduce the amplitude. A normal low-voltage swing on these pins is only a couple of hundred millivolts.
Cheers,
Håkon
Ok, my understanding there then is that the 32MHz is probably working if the radio stack is active.
Thanks for your help