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

Problems with external crystal oscillator

I use the internal LFCLOCK to drive my application. Sometimes, I need a more accurate clock
to do time measurement.
At startup, I can start the external crystal oscillator on my Fanstel module by

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.
}

This runs mostly fine, and my time measurement is accurate enough. But it consumes
too much energy (which is not always the case, is there a way to ensure, the external
oscillator is really used?), so I tried to use the external clock only when needed.
I can identify this need only within a running BLE connection.
If I start the crystal only then, I can not oberve a higher energy need.
My code to stop the external oscillator is:

NRF_CLOCK->TASKS_HFCLKSTOP    = 1;

// Wait for the external oscillator to stop
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 1){
  // Do nothing.
}

I assume, if the Softdevice and the timer peripherals are bound to internal RC,
I have to stop these, change the clock source and restart. Is this assumption
correct? If yes, is there a way to use the timer peripheral (in my case: Timer2)
driven by external oscillator only when needed without interruption of a running
BLE connection?

I use nrf52810 with softdevice 112 and SDK 15.3

Parents
  • Hi

    It seems to me like your mixing up the HF (high frequency clock/32MHz) and your LF (low-frequency/32.768kHz) clock, seeing as the code snippets include the HF clock and your text.

    If you need at any point need a more accurate LF clock, I strongly suggest that you consider using the external LF crystal that is optional in your design. The external LF crystal is more accurate and consumes less power than the internal LFRC oscillator or the LF clock that can be synthesized from the HF clock. 

    As for the external HF clock, this will be started by the SoftDevice when the SoftDevice and radio is in use, and you won't be able to control it without conflicting with the SoftDevice in your application.

    Best regards,

    Simon

Reply
  • Hi

    It seems to me like your mixing up the HF (high frequency clock/32MHz) and your LF (low-frequency/32.768kHz) clock, seeing as the code snippets include the HF clock and your text.

    If you need at any point need a more accurate LF clock, I strongly suggest that you consider using the external LF crystal that is optional in your design. The external LF crystal is more accurate and consumes less power than the internal LFRC oscillator or the LF clock that can be synthesized from the HF clock. 

    As for the external HF clock, this will be started by the SoftDevice when the SoftDevice and radio is in use, and you won't be able to control it without conflicting with the SoftDevice in your application.

    Best regards,

    Simon

Children
No Data
Related