Hi,
As far as I remember the RTC holds the time in packed BCD format. That is the upper nibble is the tens and the lower nibble is the unit. So the formula to convert it would be
Real_Hours = (10* hour_tens)+ hour_units
In PBP this would be :
Code:
CLOCK_TMP1 = (HOURS >> 4) * 10 ' PROCESS 10s BCD
HOURS = HOURS & %00001111 ' PROCESS 1s BCD
HOURS = CLOCK_TMP1+ HOURS ' ADD BOTH TO GET BINARY
Where CLOCK_TMP1 is a temporary variable. You can do it in one line to. I broke up the thing to make it more readable
While working on a PCF8563 RTC chip I noticed that the unused bits in the memory map are not always "zero". Thus it is good idea to shred off the bits not used and make them zero manually. Like:
Code:
HOURS = HOURS & %00111111 ' clear unused bits
MINUTES = MINUTES & %01111111 ' clear unused bits
Happy New Year
Bookmarks