Originally Posted by
Melanie
Convert BCD to decimal... assume variable RTCSeconds holds the seconds in BCD format...
First let's deal with the TENS value (Bits 4,5 and 6)...
DecimalSeconds=RTCSeconds & $70
DecimalSeconds=DecimalSeconds>>4
DecimalSeconds=DecimalSeconds*10
And finally add-in the UNITS value...
DecimalSeconds=DecimalSeconds+(RTCSeconds & $0F)
----
To convert Decimal back to BCD, reverse the Process...
RTCSeconds=DecimalSeconds DIG 1
RTCSeconds=RTCSeconds<<4
RTCSeconds=RTCSeconds+(DecimalSeconds DIG 0)
----
Incorporate the above into a General Purpose Subroutine and use the same single routine to convert Seconds, Minutes, Hours etc etc.
Melanie