Eduardo,
I have done some work with the read_rtc() function, so am familiar with how
it works, and I can't see any way it could fail. The RTC is really
pretty
simple - just a 48 bit ripple counter and a holding register to latch the
data while you read it. The only tricky thing is that it is possible to
latch the data in the middle of a rollover, and so get bogus data.
Read_rtc() handles this by reading the RTC repeatedly until it reads the
same value twice. I trust it.
Write_rtc I haven't looked at, so can't offer any comment.
Will
> -----Original Message-----
> From: rabbit-semi@rabb...
> [mailto:rabbit-semi@rabb...] On Behalf Of esabaj
> Sent: Sunday, January 15, 2006 11:52
> To: rabbit-semi@rabb...
> Subject: [rabbit-semi] Updating and reading the RTC
>
> I am developing an application using the RCM3700 development
> kit and I have some doubts about setting and getting the time
> from the RTC. The way I'm updating and reading the rtc is :
>
> int
> GetDateTime_RTC (struct tm *tm)
> {
> return mktm (tm, read_rtc ());
> }
>
> int
> SetDateTime_RTC (struct tm *tm)
> {
> write_rtc (mktime (tm));
> return 0;
> }
>
> However, the documentation about the tm_rd () function says
> that it may return 0 or -1 (if clock read failed), but
> looking at the code in rtclock.lib, I see that the function
> does not return anything although it should (since it returns
> an int value):
>
> nodebug
> int tm_rd(struct tm *t)
> {
> mktm(t, SEC_TIMER); // get SEC_TIMER which contains current
> time in secs
> }
>
> Surely it must be a documentation error, since mktm converts
> a value in seconds to a date/time filling the tm structure.
> It does not access the RTC.
>
> What I want to know is: could the read_rtc or write_rtc
> functions fail on any case to get or set the time from the
> RTC? It is important for me to know this, since the
> application should know the date and time without mistakes.
>
> Regards
> Eduardo
>
> Yahoo! Groups Links
>