CMOS: Difference between revisions

170 bytes added ,  13 years ago
Small wording changes regarding RTC
[unchecked revision][unchecked revision]
m (Replaced "PIC" with "PIT." (PIC is the interrupt controller, not the clock))
(Small wording changes regarding RTC)
Line 127:
8 Month
9 Year
0x32 Century (usually)
0xb Status Register B
</pre>
Line 145:
* Status Register B, Bit 2 (value = 4): Enables Binary mode if set
 
Binary mode is exactly what you would expect the value to be. If the time is 1:59:5948 AM, then the value
of hours would be 1, minutes would be 59 = 0x3b, and seconds would also be 5948 = 0x3b0x30.
 
In BCD mode, each of the two hex nibbles of the byte is modified to "display" a '''decimal''' number.
So 1:59:5948 has hours = 1, minutes = 0x59 = 89, seconds = 0x590x48 = 8972. ItTo isconvert slightlyBCD annoyingback tointo converta "good" binary value, use: binary = ((bcd / 16) * 10) + (bcd & 0xf).
BCD back into a "good" binary value.
 
24 hour time is exactly what you would expect. Hour 0 is midnight to 1am, hour 23 is 11pm.
 
12 hour time is annoying to convert back to 24 hour time. If the hour is pm, then the 0x80 bit is set on the hour byte. So you need to
mask that off. (This is true for '''both''' binary and BCD modes.) Then, midnight is 12, 1am is 1, etc.
Note that carefully: midnight is not 0 -- it is 12 -- this needs to be handled inas thea calculation fromspecial
case in the calculation from 12 hour format to 24 hour format (by setting 12 back to 0)!
 
For the weekday format: Sunday = 1, Saturday = 7.
Line 175 ⟶ 174:
cli /* Disable interrupts*/
mov al, index /* Move index address*/
/* since the 0x80 bit of al is not set, NMI is active */
out 0x70,al /* Copy address to CMOS register*/
/* some kind of real delay here is probably best */
Anonymous user