Hi,

the right way to keep the system time in sync with external RTC is
adjtime() function.

https://man7.org/linux/man-pages/man3/adjtime.3.html

NuttX also has its own implementation of adjtime()

https://github.com/apache/nuttx/blob/master/sched/clock/clock_adjtime.c,

so you can use it. Just enable CONFIG_CLOCK_ADJTIME option to include it
into compiled functions. You will need some periodic calculations of
time difference between adjtime and RTC clock in your application (some
thread that wakes up from time to time) and then to call adjtime() to
adjust the system clock. The function does not do time jump here, it
just speeds up or slows down hardware timer to adjust the time.

Best regards,

Michal

On 5/31/24 10:03, cheshmedzh...@gmail.com wrote:
> Hi all,
>
>  
>
> The testing conditions are: nuttx 2.12 runs on NUCLEO-U5A5ZJ-Q board. I have
> high accurate external RTC connected to one of i2c busses.
>
> When system runs for a long time - 2-3 days or more the time returned by
> date command is not accurate. When I reboot the system the system time
> become accurate (this is normal it is adjusted with RTC in boot process).
>
> So, the question is: What is right way to keep system time in sync with
> external RTC? 
>
>  
>
> Best regards
>
>  
>
>

Reply via email to