Re: caching of the real-time clock value
Bryan Armstrong <bryan.armstrong-6tN4nzCoH/[email protected]>
| Newsgroups | gmane.comp.hardware.microcontrollers.tini |
|---|---|
| Message-ID | <[email protected]> |
Aaron Buchanan wrote:
> I am observing problems with the consistency of calls to
> System.currentTimeMillis(). It appears that reads to the real time clock
> chip are getting cached and System.currentTimeMillis is incremented based on
> the OS tick. This results in time progressing incorrectly when compared to
> an external (non-TINI board) source. On a periodic basis (every 10 mins) it
> looks like the real-time clock gets read and System.currentTimeMillis jumps
> to the current(RTC) time. I've been observing this problem in a number of
> ways, but the easiest is with a simple test loop such as:
You are correct. The DS1672 RTC has a 1 second resolution and the
TINIOS is synchronizing the system 1ms timer every 10 minutes to allow
higher resolution. Assuming the CPU is running at 14.7456MHz, the 16
bit timer for the 1ms tick will have a 162 nanosecond overshoot per
tick. This adds up to approximately 97 milliseconds every 10 minutes.
The resync is sampled every IO_Poll (approx every 4ms) for one second to
tick over on the DS1672.
> try { Thread.sleep(1000); } catch (Exception ie) {}
The Thread.sleep() function call is not guaranteed to return in the time
requested per the Java specification. This could also lead to variance
in the timing.
> Can anyone confirm the reasons for this 10 minute reset/anomaly I'm seeing
> in time reading? Is there a way to always read from the RTC? If I used the
> System_GetRTCRegisters native api function will it return the raw RTC value,
> or is it being cached also?
The native function grabs the system time plus offset just as the
currentTimeMillis() function does. You can always divide the current
time by 1000 to get a seconds count that equals the value of the RTC.
--
--
Bryan Armstrong
bryan.armstrong-6tN4nzCoH/[email protected]
_______________________________________________
TINI mailing list
TINI-6tN4nzCoH/[email protected]
To UNSUBSCRIBE, edit your profile, or see list archives:
http://lists.dalsemi.com/mailman/listinfo/tini