home *** CD-ROM | disk | FTP | other *** search
- Chapter 11
-
- System Timer and Real Time Clock Services
- -----------------------------------------
- 1. Introduction
- The ROM BIOS contains five time-related services, INT 08h, INT 1Ah,
- INT 1Ch, INT 4Ah and INT 70h. The system has an Intel 8254 (or 8253)
- timer chip to generate a timer tick 18.2 times per second and issue
- INT 8 and INT 1Ch. The system has a MC146818A real time clock also.
- It generates 1024 timer tick per second, and contains 64 bytes of
- CMOS. INT 1Ah is used to access the first 12 bytes of CMOS that
- contain time related data. INT 70h is the RTC ISR and INT 4Ah is the
- user Alarm interrupt that is invoked by INT 70h.
-
- 2. Diagram of Service Routines
-
- ┌──────────────┬────────────────────┬─────────────────┐
- │ MC146818A │ CMOS data 00-0C,32 │ CMOS data 0D-3F │
- │ │ Time data │ BIOS using │
- └──────┬───────┴────────────────────┴─────────────────┘
- │
- └───┐ │
- │ INT 1Ah
- INT 70 │ ┌──────────────┐
- ┌──────────┬──────────┐ C │ Fun 00,01 │
- │Periodic │ Alarm │ │ │ Read/Set ├──┐
- │Interrupt │ Interrupt│<──┐ │ │ System timer │ │
- └────┬─────┴────┬┬────┘ │ │ ├──────────────┤ │
- │ ││ │ │ │ Fun 02-05 │ │
- │ ││ │ ├──┤ Read/Set RTC │ │
- F EE │ │ time and day │ │
- │ ││ │ D ├──────────────┤ │
- │<─────────┘│ │ └──┤ Fun 06,07,09 │ B
- │ │ └──────┤Set/Reset/Read│ │
- │ │ RTC alarm │ │
- │ ┌────────┐ └──────────────┘ │
- │ │ INT 4A │ │
- │ └────────┘ │ ┌────────┐
- │ │ │ 8254 │
- │ BIOS data │ └────┬───┘
- │ ┌──────────────┐ │ │
- │ │ system timer │ <──────┘
- │ │40:6c - 40:70 │ <─┐ ┌────────┐
- │ ├──────────────┤ └────-A─────┤ INT 8 │
- │ │ RTC data │ └────┬───┘
- └───────────────-> │40:98 - 40:a6 │ A
- └──────────────┘
- ┌────────┐
- │ INT 1C │
- └────────┘
-
- 3. Programming
-
- INT 8 -- A timer tick is generated by 8254 18.2 times per second,
-
- Increase the timer count to reach the value of one day and
- then reset the timer counter and set the timer-overflow
- flag.
-
- Decrement motor off couter and when the count reaches 0,
- turn the diskette drive motor off, and reset the flag of
- motor running.
-
- Finally, issue interrupt 1CH which can be provided by the
- user.
- ------ A
-
- INT 1A -- Subfunction 0 and 1 : Read/Set system-time timer counter
- from BIOS data.
- ------ B
-
- Subfunction 2-5 : Read/Set real-time clock time and date.
- Before reading CMOS, data must wait for the RTC time
- (status register A bit 7). Before writing to CMOS,
- data must be clear status register B bit 7 (in set mode),
- and when the operation is finished, set this bit again.
- Error condition : RTC error and time update in progress
- for a long time. (loop 1000h times)
- ----- C
-
- Subfunction 6 : Set RTC alarm.
- check RTC status.
- set alarm interrupt enable.
- set alarm time.
- enable interrupt of 8259.
- Subfunction 7 : Reset RTC alarm.
- disable alarm interrupt of register B.
- Subfunction 9 : Read alarm time of RTC and status.
- ----- D
-
- INT 70 -- RTC interrupt service routine
- test the occurrence of an interrupt (if not then send EOI
- only)
- a. alarm interrupt : send EOI and issue INT 4A
- ----- E
-
- b. periodic interrupt : decrease wait_time (40:a2,a4)
- 1000 if no more counter then set
- user periodic flag (address of
- 40:98) and disable PIE.
- ----- F
-
-