Hi,
I have following problem:
I try to synchronize specific event let's say every three seconds. My simple test is just looping date_time_now() and taking modulus out of it to desire if its full 3000ms cycle.
However, I found that I'm always approximately 3% off the initial value I'm expecting. If my date_time_now() says 3000ms has been elapsed it is only 2930ms and 10000ms is 9700ms etc. How come there is HUGE deviation from the result I'm expecting. I'm assuming date_time should be able to deliver better accuracy even its not intended for super precise use..
I have configured everything correctly according my best knowledge. LFXO is configured as a clock source for clock_ns and overall system as LTE-M modem is working properly(?). I checked with debugger that clock_ns shows clocksource LFXO but clock_s shows LFRC.
I have tried to change multiple proj.cfg settings for hours without any improvement.
Hopefuly this makes any sense and somebody could have any directions?

while(1)
{
uint64_t timeMs;
date_time_now(&timeMs);
if(timeMs % 3000 == 0)
{
LOG_INF("Current time in ms: %lld", (long long int)timeMs);
if(state)
{
gpio_pin_set_dt(&enableled, 0);
pwm_set_dt(&pwm_spec_led, 62500, 0);
state = false;
}
else
{
gpio_pin_set_dt(&enableled, 1);
pwm_set_dt(&pwm_spec_led, 62500, 625);
state = true;
}
}
}