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

nRF52832 DK clk/interrupt is un-deterministic

I am trying to trigger some functions based on some pre-determined timings. I tried to do that using nrf_delay_us and also using timer0 interrupts, but both are giving me un-deterministic timings. So for a delay of 1 second using the delay or the timer methods both give more like ~999,980 us. I tried to force CONSTLAT but for some reason in the debugger I can see that the command has no effect on the TASKS_CONSTLAT bit.

  • 999,980 us is pretty close to 1 second. You will have inaccuracies in the clock. If you are not starting the crystal (HFXO) you will run off the internal oscillator (HFINT) which have a typical accuracy of 1.5%, see here. In comparison, the crystal on the DK have accuracy of 20ppm. With 1.5% accuracy you should expect the timing to be within 1500us when counting one second, with 20ppm expect up to 20us error.

    Also if you are using delays, the time between functions will be the time it takes to execute the function plus the delay time. If you use timer peripheral and clear the timer using shortcuts you should not expect added time because of function execution.

    In constant latency mode the CPU wakeup latency and the PPI task response will be constant and kept at a minimum. So it will only apply if the chip enters sleep (__WFE()). Constant latency mode will increase the sleep power consumption.

Related