8254 Timer Counter
8254 Timer Counter
8254 Timer Counter
Motivation
We want to explore the Pentiums support for multiprocessing (as distinguished from multitasking, which we already examined) The algorithms for multiprocessor startup will require us to use some timed delays (for example, a delay of 10 milliseconds) Various other systems programming tasks require the use of carefully timed delays
MSB GATE
LSB
OUT
LATCH REGISTER
STATUS
TIMER/COUNTER CHANNEL
OUT0
Interrupt IRQ0
GATE1
CLK2 GATE2 Port 0x61, bit #0 +5 V
Channel 1
OUT1
DRAM refresh
8254 PIT
8254 Command-Port
7 6 5 4 3 2 1 0 binary / BCD
CHANNEL
COMMAND
OUTPUT MODE
Output Mode Counting Mode Command-ID 000 = one-shot level 0 = binary 00 = Latch 001 = retriggerable 1 = BCD 01 = LSB r/w 010 = rate-generator 10 = MSB r/w 11 = LSB-MSB r/w 011 = square-wave 100 = software strobe 101 = hardware strobe
6
R/O
5
R/O
4
R/O
3
R/W
2
R/W
1
R/W
0
R/W
OUT2 1 = on 0 = off
i/o channel speaker check 1 = on enable OUT1 memory 0 = off 1 = on parity 0 = off check enable
GATE2 1 = on 0 = off
Algorithm (continued)
Step 3: compute the frequency-divisor for a ten millisecond delay (one hundredth of one second) by dividing CLK2 frequency (1,193,182 Hz) by one-hundred Step 4: write quotients LSB, followed by its MSB, to channel 2 Latch (io-port 0x42)
Algorithm (concluded)
Divide cycle-count by ten-thousand, to get processors clock-speed in Mega-Hertz (i.e., in millions of cycles-per-second) Display this quotient in decimal format!
In-class exercise
The Real-Time Clock chip automatically updates its clock/calendar registers once each second Register values cannot be reliably read while the RTCs update is in progress Most significant bit in RTC register 0x0A provides indication of update-in-progress How long does the RTC update last?