CMOS: Difference between revisions

24 bytes added ,  13 years ago
m
BCD conversion bugfix
[unchecked revision][unchecked revision]
m (Interwiki)
m (BCD conversion bugfix)
Line 151:
 
In BCD mode, each of the two hex nibbles of the byte is modified to "display" a '''decimal''' number.
So 1:59:48 has hours = 1, minutes = 0x59 = 89, seconds = 0x48 = 72. To convert BCD back into a "good" binary value, use: binary = ((bcd / 16) * 10) + (bcd & 0xf) ''[Optimised: binary = ( (bcd & 0xF0) >> 1) + ( (bcd & 0xF0) >> 3) + (bcd & 0xf)]''.
 
24 hour time is exactly what you would expect. Hour 0 is midnight to 1am, hour 23 is 11pm.
250

edits