Accuracy issue between k_uptime_ticks() and hardware pwm outputs

Running into a slight issue where the timebase for system (reference time + uptime aka k_uptime_ticks()) drifts relative to sensor sampling rates.
Attempt to synchronize the timebases by using nRF53 pwm system to output clock for external sensors still drifts as the timebase for pwm appears to be HFCLK based of HF XTAL while system ticks come from LFCLK based of LF XTAL.

What is the recommended method to synchronize these while keeping power consumption low?
CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH may be an option but how will this impact power consumption, and will it prevent sleep?

  • I see, that sounds like a probable root cause, indeed. I hope taking care of this stray function call let you get down to the expected current consumption numbers again. If not, let me know, and I will take another look.

    Best regards,

    Simon

  • I can confirm with the PPKII that the power consumption is back to expected level and the hack using 1 timer and RTC0 with the DPPI system did not increase consumption much at all.

    Zephyr appears to use RTC1 however and ideally one would just want to use a tick event from that instead of enabling an extra RTC. I tried this and it appears to either throw off Zephyr task scheduling or confuse it. I assume this is because Zephyr does not expect anyone to change anything on it's RTC and I believe it must be stopped in order to do so as well.
    Since there was not any noticeable extra draw I think this is ok.

Related