Hello,
Our design uses Laird's BL652, which uses nRF52832. I need to calculate the maximum clock drift of timers given the crystals used in our design. Our application uses a simplified version of your wireless timer synchronization blog to synchronize timers of two peripherals. I need to determine, based on clock drift, the sync period necessary to keep clocks within 1 ms of each other.
Our design uses this crystal for the low frequency clock and the BL652 data sheet specifies:
5.2.1 Clocks
The integrated high accuracy 32 MHz (±10 ppm) crystal oscillator helps with radio operation and reducing power consumption in the active modes.
I understand that the timers of nRF52832 run on the high-frequency clock source. Does this mean that nRF52832 timers have maximum drift of ±10 ppm? Given I am synchronizing timers of two different nRF52832s, maximum drift between the two would be ±20 ppm?
At ±20 ppm, I calculate 1 ms drift between timers of two peripherals occurs in minimum 50 seconds (1.728 seconds drift per day, 72 milliseconds drift per hour, 1 millisecond drift in 50 seconds). Currently I re-sync the timers every 30 seconds. Am I correct?
main() has this code:
err_code = sd_power_mode_set(NRF_POWER_MODE_CONSTLAT);
APP_ERROR_CHECK(err_code);
// start the high frequency clock
uint32_t is_running;
sd_clock_hfclk_request();
do {
sd_clock_hfclk_is_running(&is_running);
} while (is_running==0);
Related question: Our low frequency external crystal is ±5 ppm. Should I change NRF_SDH_CLOCK_LF_ACCURACY in sdk_config.h from:
// <o> NRF_SDH_CLOCK_LF_ACCURACY - External clock accuracy used in the LL to compute timing. // <0=> NRF_CLOCK_LF_ACCURACY_250_PPM // <1=> NRF_CLOCK_LF_ACCURACY_500_PPM // <2=> NRF_CLOCK_LF_ACCURACY_150_PPM // <3=> NRF_CLOCK_LF_ACCURACY_100_PPM // <4=> NRF_CLOCK_LF_ACCURACY_75_PPM // <5=> NRF_CLOCK_LF_ACCURACY_50_PPM // <6=> NRF_CLOCK_LF_ACCURACY_30_PPM // <7=> NRF_CLOCK_LF_ACCURACY_20_PPM // <8=> NRF_CLOCK_LF_ACCURACY_10_PPM // <9=> NRF_CLOCK_LF_ACCURACY_5_PPM // <10=> NRF_CLOCK_LF_ACCURACY_2_PPM // <11=> NRF_CLOCK_LF_ACCURACY_1_PPM #ifndef NRF_SDH_CLOCK_LF_ACCURACY #define NRF_SDH_CLOCK_LF_ACCURACY 7
to:
#ifndef NRF_SDH_CLOCK_LF_ACCURACY #define NRF_SDH_CLOCK_LF_ACCURACY 9
Many thanks,
Tim