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