[En-Nut-Discussion] Possible bug in the Ethernut 3 RTC code
Douglas Pearless
Douglas.Pearless at pearless.co.nz
Fri Mar 30 01:41:46 CEST 2007
I have been trying to track down a wierd bug with setting and
reading the year from the RTC.
I tracked it down to x12rtc.c where the routine X12RtcGetClock has
the following lines:
if (BCD2BIN(data[7]) > 0x19) {
tm->tm_year += 100;
}
Now on the X1286 chip used on my Ethernut 3 revision E board (note
the D board used the X1226 chip, whose data[7] is the Y2K register),
data[7] is the 1/100 second register as shown in the datasheet, so the
year comes back from X12RtcGetClock either as 2007 or 2107 depending
on the 1/100 second register!
As I don't think the watchdog timer on the x1826 is used, then that
represents a difference between the two possible chips for the
Ethernut 3 boards, and hence by checking that the WD0 and WD1 bits are
set (i.e. the watchdog is disabled, its default setting), the we have
a x1286 chip and therefore need to ignore those two lines of code, and
changes are also required in the X12RtcSetClock routine.
OR should this be controller through the NUTOS configurator?
What do other people think?
Cheers Douglas.
More information about the En-Nut-Discussion
mailing list