Lecture 2 8086 Interrupt
Lecture 2 8086 Interrupt
Lecture 2 8086 Interrupt
a
The Intel 8259A Programmable Interrupt Controller handles up to eight
vectored priority interrupts for the CPU.It is cascadable for up to 64 vectored
priority interrupts without additional circuitry. It is packaged in a 28-pinDIP,
uses NMOS technology and requires a single 5V supply.
The 8259A is designed to minimize the software and real time overhead
in handling multi-level priority interrupts. It has several modes, permitting
optimization for a variety of system requirements.
13
82C59A Programmable Interrupt
Controller
Block diagram of the 82C59A
14
Internal architecture of the 82C59A
7
Cascade lines (CAS2-CAS0):
The cascade lines (CAS2-CAS0) are used as outputs from the master to the slaves for cascading
multiple 8159As in a system. The master outputs a 3-bit slave identification number on these lines.
Each slave in a system is assigned a 3-bit ID as part of its initialization. Sending this 3-bit ID number
enables the slave.
Slave program/Enable buffer (𝐒𝐏/𝑬𝑵):
This pin is a dual function pin, when the 8259A is in buffered mode, this is an output that controls the
data bus transceivers in a large microprocessor based system. When the 8259A is not in the buffered
mode, this pin programs the device as a master (1) or a slave(0). When we use only one 8159A in our
system, the 𝐒𝐏/𝑬𝑵 pin is tied high (1).
INT Pin:
The interrupt output (INT) pin of 8259A is connected to the INTR pin on the microprocessor (8086)
when there is only one 8259A in the system. In a system with master and slaves, only master’s INT pin
is connected to 8086. The slave’s INT pins are connected to different IR pins of the master.
8
Interrupt acknowledge (𝑰𝑵𝑻𝑨 ) pin:
This input pin of 8259A is connected to the 𝑰𝑵𝑻𝑨 output of the 8086.
Interrupt request inputs(𝐈𝐑𝟕 − 𝐈𝐑𝟎) :
The eight interrupt request inputs (IR7-IR0) are used to request an interrupt by the external devices in
case of single 8159A system. In case of multiple 8259A system these input pins (IR7-IR0) of the master
is connected to output INT pins of the slaves. Unused IR inputs should be tied to ground so that a noise
pulse can not accidentally cause an interrupt. An interrupt signal must remain high on an IR input until
after the falling edge of the first 𝑰𝑵𝑻𝑨 pulse.
9
Internal Block Diagram of 8259A
The Interrupt Request Register (IRR):
The IRR keeps track of which interrupt inputs are asking for service. If an interrupt input has an
interrupt signal on it, then the corresponding bit in the IRR will be set.
10
82C59A Programmable Interrupt
Controller (PIC)
15
The initialization of the PIC is rather complicated because it has many possible operating
modes.
ThePIC’s operating mode is normally initialized by theBIOSwhen the system is booted.
We will only consider thestandard PIC operating used on the IBM PC and only asystem
with a single (master) PIC.
ICW1
ICW2
NO (SNGL=1)
IN CASCADE
MODE ?
YES (SNGL=0)
ICW3
NO (IC4=0) IS ICW4
NEEDED ?
YES (IC4=1)
ICW4
Initialization sequence of
the ICWs in 82C59A
READY TO ACCEPT
INTERRUPT REQUESTS
Controller
Initialization command words
ICW1
Bits ADI, A7, A6, A5 are don’t care for microprocessor operation and only
apply to the 8259A when used with an 8-bit 8085 microprocessor
82C59A Programmable Interrupt
Controller
EXAMPLE
What value should be written into ICW1 in order to configure the
82C59A so that ICW4 is needed in the initialization sequence, the
system is going to use multiple 82C59As, and its inputs are to be
level sensitive? Assume that all unused bits are to be logic 0.
Solution:
Since ICW4 is to be initialized, D0 must be logic 1, D0 = 1
For cascaded mode of operation, D1 must be 0, D1 = 0
And for level-sensitive inputs, D3 must be 1, D3 = 1
Bits D2 and D5 through D7 are don’t-care states and are 0.
D2 = D5 = D6 = D7 = 0
Moreover, D4 must be fixed at the 1 logic level, D4 = 1
This gives the complete command word
D7D6D5D4D3D2D1D0 = 000110012 = 1916
ICW2: Selects the vector number used with the interrupt request inputs. For example,
if we decide to program the 8259A so it functions at vector locations 08H0FH,
we place 08H in the command word
17
82C59A Programmable Interrupt
Controller
EXAMPLE
What should be programmed into register ICW2 if the type
numbers output on the bus by the device are to range from F016
through F716?
Solution:
To set the 82C59A up so that type numbers are in the range of F016
through F716, its device code bits must be
D7D6D5D4D3 = 111102
The lower three bits are don’t-care states and all can be 0s. This
gives the word
D7D6D5D4D3D2D1D0 = 111100002 = F016
18
82C59A Programmable Interrupt
Controller
EXAMPLE
Assume that a master PIC is to be configured so that its IR0
through IR3 inputs are to accept inputs directly from external devices,
but IR4 through IR7 are to be supplied by the INT outputs of slaves.
What code should be used for the initialization command word ICW3?
Solution:
For IR0 through IR3 to be configured to allow direct inputs from
external devices, bits D0 through D3 of ICW3 must be logic 0:
D3D2D1D0 = 00002
The other IR inputs of the master are to be supplied by INT outputs
of slaves. Therefore, their control bits must be all 1:
D7D6D5D4 = 11112
This gives the complete command word
D7D6D5D4D3D2D1D0 = 111100002 = F016
19
82C59A Programmable Interrupt
Controller
Operational command words
OCW1 is used to access the contents of the
interrupt-mask register (IMR). Setting a bit to logic
1 masks out the associated interrupt input.
20
82C59A Programmable Interrupt
Controller
Operational command words
OCW2 is used to select appropriate priority scheme and
assigns an IR level for the scheme.
Solution:
To enable the rotate on nonspecific EOI command priority scheme,
bits D7 through D5 must be set to 101. Since a specific level does
not have to be considered, the rest of the bits in the command word
can be 0. This gives OCW2 as
21
82C59A Programmable Interrupt
Controller
Operational command words
OCW3 permits reading of the contents of the ISR or IRR
registers through software.
Minimum-mode interrupt interface for the 8088 microcomputer using the 82C59A
23
8259A Operating Modes:
lowest priority.
• It is suitable for a single 8259 configuration.
lowest priority.
• All other priorities rotate according to it.
It works as follows:
5. Poll mode :
Poll mode in the 8259 (Programmable Interrupt
Controller) is an alternative way for the
microprocessor (μP) to manage interrupts instead of
relying on their automatic delivery via interrupt lines.
Here's a brief explanation:
The μP actively queries the 8259 using a specific
command ("poll command") via OCW3 instead of
passively waiting for an interrupt signal.
In response, the 8259 sends a "poll word" back to the
μP, indicating the highest-priority pending interrupt (if
any).
The μP then identifies the source of the interrupt and
proceeds to service it.
How it works:
EXAMPLE
Analyze the circuit in the following figure and write an
appropriate main program and a service routine that counts as a
decimal number the positive edges of the clock signal applied to the
IR0 input of the 82C59A.
25
Interrupt Interface Circuits Using the 82C59A
Software organization:
Interrupt Interface Circuits Using the
82C59A
Flowcharts of the main program and service routine:
Main Program SRV72
Set up data segment,
Save processor
stack segment, and
status
stack pointer
Wait for
interrupt
the 82C59A
Program:
;MAIN PROGRAM
CLI ;Start with interrupt disabled
START: MOV AX, 0 ;Extra segment at 00000H
MOV ES, AX
MOV AX, 1000H ;Data segment at 01000H
MOV DS, AX
Note:
Victore type=72 MOV AX, 0FF00H ;Stack segment at 0FF00H
72 x 4 = 288 = 120H MOV SS, AX
MOV SP, 100H ;Top of stack at 10000H
27
Interrupt Interface Circuits Using
the 82C59A
Program:
Nonmaskable Interrupt
The nonmaskable interrupt (NMI) is initiated from external
hardware.
Differences between NMI and other external interrupts:
NMI can not be masked out with the interrupt flag.
Request for NMI service are signaled to the 8088/8086
microprocessor by applying logic 1 at the NMI input, not the
INTR input.
NMI input is positive edge-triggered. Therefore, a request for
NMI is automatically latched internal to the MPU.
NMI automatically vectors from the type 2 vector location
in the pointer table (000816 ~000A16)
Typically, the NMI is assigned to hardware events that
must be responded to immediately, such power failure.
29
Reset
The RESET input of the 8088 and 8086
microprocessors provides a hardware means for
initializing the microcomputer.
Reset
30
Reset
When the MPU recognizes the RESET input, it
initiates its internal initialization routine. At completion
of initialization, the flags are all cleared, the registers
are set to the values in the following table.
CPU COMPONENT CONTENT
Flags Clear
Instruction pointer 0000H
CS Register FFFFH
DS Register 0000H
SS Register 0000H
ES Register 0000H
Queue Empty
Reset
The external hardware interrupts are disabled after
the initialization.
Program execution begins at address FFFF016 after
reset. This storage location contains an instruction
that will cause a jump to the startup (boot-strap)
program that is used to initialize the reset of the
microcomputer system’s resources, such as I/O ports,
the interrupt flag, and data memory.
After the system-level initialization is complete,
another jump can be performed to the starting point
of the microcomputer’s operating system or
application program.
31
Internal Interrupt Functions
Four of the 256 interrupts of the 8088 and 8086 are
dedicated to internal interrupt functions.
Internal interrupts differ from external hardware
interrupts in that they occur due to the result of
executing an instruction, not an event that takes
place in external hardware.
Internal interrupts are not masked out with IF flag.
Internal interrupts of the 8088 and 8086 MPU:
Divide error (Type number 0)
Single step (Type number 1)
Breakpoint interrupt (Type number 3)
Overflow error (Type number 4)
32