Lecture 8 - Programmable Interval Timer
Lecture 8 - Programmable Interval Timer
5 From the book The 8088 and 8086 Microprocessors by Triebel and Singh. 6
Pg 510
7 8
Control Word (III) - Read Back Mode (I) Control Word (III) - Read Back Mode (II)
Read-Back Command Format
Permits programmer to capture
the current count values and
status information of all three
counters with a single command.
D7 and D6 must be 1
Example:
To capture the values in all
three counters
DE16 or 110111102 must
Status Byte (RD = 0; to be read by CPU) be written into the Control
Word Register.
Programmer must next
read these values by
issuing read commands for
the individual counters
Slide 7
9 From the book The 8088 and 8086 Microprocessors by Triebel and Singh. 10
Pg 514
13 14
Counter 2
To speaker and PC5 of 8255 1) Disables counting
Mode 3 2) Sets output Initiates counting Enables counting
896 Hz (1.193MHz / 1331) immediately high
Mode 3, control word: B6H
GATE2 is connected to PB0 (port 61H) Mode 4 Disables counting -- Enables counting
Delay 400 µs
19 20
Mode 2 (Rate Generator) Mode 2 (cont’)
Operate as divide by N counter Mode 2: Counter generates a series of pulses
N = Value of the count loaded into the counter (negative) of 1 clock pulse wide.
As long as GATE# = 1, The separation between pulses is determined
OUT# will be high for N*T and Low for 1*T
by the count.
The cycle is repeated until reprogrammed or G
pin set to 0.
21 22
23 24
Mode 4 (Software Triggered Strobe Counter) Mode 4 (cont’)
GATE# input needs to be logic 1 for counter to function
Starts upon loading the count
High for (N+1) clock pulses, low for 1 clock pulse and Mode 4: Software triggered one-shot (G
then high again must be 1).
Similar to Mode 2 except the counter is not automatically
reloaded
6
601
601
25 26
27 28
Solution
Example First, we need to determine the base address of the 82C54. the base address,
which is also the address of counter 0, is determined with A1A0 set to 00.
In the figure we find that to select the 8254, /CS must be logic 0. This requires
Write an instruction that
sequence to set up the A15 -> A2 = 000000000010000
three counters of the Combining this part of the address with the 00 at A1A0, gives the base address
82C54 in the Figure beside, as
0000000001000000=40H
as follows:
Counter 0 = Binary counter Since the base address of the 8254 is 40H, and to select the mode register
operating in mode 0 with an requires A1A0 =11, its address is 43H. Similarly, the three counters 0, 1, and 2
are at addresses 40H, 41H, 42H, respectively. Let us first determine the mode
initial value of 1234H. words for the three counters. We get
Counter 1 = BCD counter Mode word for counter 0 = 00110000 = 30H
operating in mode 2 with an Mode word for counter 1 = 01110101 = 75H
initial value of 0100H. Mode word for counter 2 = 10111000 = B8H
Counter 2: Binary counter The following instruction sequence can be used to set up the 8254 with the
operating in mode 4 with an desired mode words and counts:
initial value of 1FFFH.
Solution Example
MOV AL,30H ;Set up counter 0 mode Program counter 1 of the 8254 so that it generates a
OUT 43H,AL
MOV AL,75H ;Set up counter 1 mode continuous series of pulses that have a high time of
OUT 43H,AL 100us and a low time of 1us. Make sure to indicate the
MOV AL,0B8H ;Set up counter 2 mode CLK frequency required for this task. USING A 1MHZ
OUT 43H,AL
MOV AL,1234H ;Initialize counter 0 with 1234H CLOCK
OUT 40H,AL
MOV AL,12H
OUT 40H,AL
MOV AL,0100H ;Initialize counter1 with 0100H CONTROL = Address
of control word register
OUT 41H,AL
MOV AL,01H MOV AL,74H 65H=101 dec
OUT 41H,AL OUT CONTROL,AL
74H=0111 0100 MOV AL,65H ;count of 101dec
MOV AL,1FFFH =>01 =counter1
OUT 42H,AL ;Initialize counter2 with 1FFFH OUT TIMER1,AL
=>11 = LSB followed
MOV AL,1FH by MSB MOV AL,0 TIMER1 = Address of
OUT 42H,AL =>010 = mode 2 OUT TIMER1,AL counter 1
=>0 = Binary
31 32