Shop OBEX P1 Docs P2 Docs Learn Events
Using the Real Time Clock to display the date in month day, year format — Parallax Forums

Using the Real Time Clock to display the date in month day, year format

ArchiverArchiver Posts: 46,084
edited 2001-09-24 06:10 in General Discussion
Hi all,
I know the DS1302 has the capability to display date as well as time.
I even have a data sheet which can be downloaded in .pdf format from
Dallas Semiconductor website (http://dbserv.maxim-
ic.com/quick_view2.cfm?qv_pk=2685)

I am aware that all units of measurement are in a byte-sized variable
in BCD format.

However, I don't understand one line of code in the SetTime and
GetTime subroutines (Experiment #30 from the Stampworks book V1.1)

SetTime: SHIFTOUT Dio,Clock,LSBFirst,[noparse][[/noparse]secs,mins,hrs,0,0,day,0,0]
GetTime: SHIFTIN Dio,Clock,LSBPre,[noparse][[/noparse]secs,mins,hrs,day,day,day]

From the SetTime subroutine, it is apparent that the lower 7 bits are
only looked at for the hours, minutes, and seconds. I believe the 0's
following hrs come from Bits 6 and 7 respectively from the hour
register definition. The day register has the 5 most significants set
to 0 with lowest 3 corresponging to the BCD format for the day (1-7).
The GetTime subroutine doesn't seem as obvious. How come the last
three variables are day? This question is baffling me.

Any clarification will help me come up with a date on the DEBUG
screen (and later on the LCD). From the data sheet, I have the
following information:

For the date itself:
10's of date (1-3): Bits 4 and 5
1's of date (0-9): Bits 0-3 (lower nibble)

For the month:
10's of month (0-1): Bit 4
1's of month (0-9): lower nibble

For the year (this is where I'm confused):
10's of year (00-99): Upper nibble?
1's of year (00-99):Lower nibble?

Here's how the data sheet shows this:

|
|
|
00-99 | 10 year | year |
|
|
|

Not sure how to interpet that. Only sense I could make is that the
year is a 2-digit number and not a 4-digit but that would seem to
contradict what the Stampworks book claims of "leap year compensation
valid up to the year 2100"? It is not to clear to me the earliest
year that is valid? Is it 2000,0, 1900, or some other year? If it is
2000, then it would make a little sense.

Any expert advice on this matter, as always, would be appreciated.

Sincerely,
RP
Sign In or Register to comment.