CMOS: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
Small wording changes regarding RTC |
Added/moved Brendan's RTC code to this article |
||
Line 115: | Line 115: | ||
=== Getting Current Date and Time from RTC === |
=== Getting Current Date and Time from RTC === |
||
To get each of the following date/time values from the RTC, |
To get each of the following date/time values from the RTC, you should first verify that Status Register A |
||
is not in "update mode" (Bit 7, value = 0x80 is clear). Then select the associated "CMOS register" in the |
|||
[[#Accessing CMOS Registers|usual way]], and read the value from Port 0x71. |
[[#Accessing CMOS Registers|usual way]], and read the value from Port 0x71. |
||
Line 128: | Line 129: | ||
9 Year |
9 Year |
||
0x32 Century (usually) |
0x32 Century (usually) |
||
0xa Status Register A |
|||
0xb Status Register B |
0xb Status Register B |
||
</pre> |
</pre> |
||
Line 209: | Line 211: | ||
} |
} |
||
</source> |
</source> |
||
=== Reading All RTC Registers === |
|||
<pre> |
|||
%define RTCaddress 0x70 |
|||
%define RTCdata 0x71 |
|||
;Get time and date from RTC -- values may be binary or BCD |
|||
.l1: mov al,10 ;Get RTC register A |
|||
out RTCaddress,al |
|||
in al,RTCdata |
|||
test al,0x80 ;Is update in progress? |
|||
jne .l1 ; yes, keep polling |
|||
mov al,0 ;Get seconds (00 to 59) |
|||
out RTCaddress,al |
|||
in al,RTCdata |
|||
mov [RTCtimeSecond],al |
|||
mov al,0x02 ;Get minutes (00 to 59) |
|||
out RTCaddress,al |
|||
in al,RTCdata |
|||
mov [RTCtimeMinute],al |
|||
mov al,0x04 ;Get hours (value may be 12hr or 24hr format) |
|||
out RTCaddress,al |
|||
in al,RTCdata |
|||
mov [RTCtimeHour],al |
|||
mov al,0x07 ;Get day of month (01 to 31) |
|||
out RTCaddress,al |
|||
in al,RTCdata |
|||
mov [RTCtimeDay],al |
|||
mov al,0x08 ;Get month (01 to 12) |
|||
out RTCaddress,al |
|||
in al,RTCdata |
|||
mov [RTCtimeMonth],al |
|||
mov al,0x09 ;Get year (00 to 99) |
|||
out RTCaddress,al |
|||
in al,RTCdata |
|||
mov [RTCtimeYear],al |
|||
ret |
|||
</pre> |
|||
== See Also == |
== See Also == |