MODULE 3 MP
MODULE 3 MP
Interrupts of 8086- Dedicated Interrupt types- Software interrupts-Hardware interrupts- Priority of interrupts-Programmable
Interrupt Controller (8259)
Organisation and Interfacing of PPI (8255), and Keyboard and display Interface (8279)
3.2.1 To describe Programmable Peripheral Interfacing Chip and Interfacing with x86 processor
3.2.2 To explain the importance, organisation, and interfacing of Programmable Interrupt Controller
3.2.3 To describe Keyboard and Display Interface chip and Interfacing with x86 processor
INTERRUPTS OF 8086
An interrupt is a condition that halts the microprocessor temporarily to work on a different task and then return
to its previous task.
Interrupt is an event or signal that request to attention of CPU. This halt allows peripheral devices to
access the microprocessor.
Whenever an interrupt occurs the processor completes the execution of the current instruction and starts the
execution ofan Interrupt Service Routine (ISR) or Interrupt Handler.
ISR is a program that tells the processor what to do when the interrupt occurs.
After the execution of ISR, control returns back to the main routine where it was interrupted.
In 8086 microprocessor following tasks are performed when microprocessor encounters an interrupt:
1. The value of flag register is pushed into the stack. It means that first the value of SP (Stack Pointer) is
decremented by 2 then the value of flag register is pushed to the memory address of stack segment.
2. The value of starting memory address of CS (Code Segment) is pushed into the stack.
3. The value of IP (Instruction Pointer) is pushed into the stack.
For every interrupt, there must be an interrupt service routine (ISR), or interrupt handler.
When an interrupt is invoked, the microprocessor runs the interrupt service routine.
For every interrupt, there is a fixed location in memory that holds the address of its ISR. The group of memory
locationsset aside to hold the addresses of ISRs is called the interrupt vector table.
When an interrupt is occurred, the microprocessor stops execution of current instruction. It transfers the content of
programcounter into stack.
It also stores the current status of the interrupts internally but not on stack. After this, it jumps to the memory
location specified by Interrupt Vector Table (IVT). After that the code written on that memory area will
execute.
The interrupt vector (or interrupt pointer) table is the link between an interrupt type code and the procedure that
has beendesignated to service interrupts associated with that code. 8086 supports total 256 types i.e. 00H to FFH.
For each type it has to reserve four bytes i.e. double word. This double word pointer contains the address of the
procedurethat is to service interrupts of that type.
The higher addressed word of the pointer contains the base address of the segment containing the procedure.
This baseaddress of the segment is normally referred as NEW CS.
The lower addressed word contains the procedure’s offset from the beginning of the segment. This offset is
normallyreferred as NEW IP.
Thus NEW CS: NEW IP provides NEW physical address from where user ISR routine will start.
As for each type, four bytes (2 for NEW CS and 2 for NEW IP) are required; therefore interrupt pointer table
occupies upto the first 1k bytes (i.e. 256 x 4 = 1024 bytes) of low memory.
The total interrupt vector table is divided into three groups namely,
This interrupt occurs whenever there is division error i.e. when the result of a division is too large to be stored.
This condition normally occurs when the divisor is very small as compared to the dividend or the divisor is zero.
Its ISR address is stored at location 0 x 4 = 00000H in the IVT.
It puts microprocessor in single stepping mode i.e. the microprocessor pauses after executing every
instruction. This is very useful during debugging.
Its ISR generally displays contents of all registers. Its ISR address is stored at location 1 x 4 = 00004H in
the IVT.
INT 2 (Non mask-able Interrupt)-
The microprocessor executes this ISR in response to an interrupt on the NMI (Non mask-able Interrupt) line.
Its ISR address is stored at location 2 x 4 = 00008H in the IVT.
INT 3 (Breakpoint Interrupt)-
This interrupt is used to cause breakpoints in the program. It is caused by writing the instruction INT
03H or simply INT.
Its ISR is used to display the contents of all registers on the screen. Its ISR address is stored at location 3
x 4 =0000CH in the IVT.
INT 4 (Overflow Interrupt)-
This interrupt occurs if the overflow flag is set and the microprocessor executes the INTO (Interrupt on
Overflow) instruction.
It is used to detect overflow error in signed arithmetic operations.
Its ISR address is stored at location 4 x 4 = 00010H in the IVT.
These levels are reserved by Intel to be used in higher processors like 80386, Pentium etc. They are not available
to the user.
ISRs for these interrupts are written by the users to service various user defined conditions.
These interrupts are invoked by writing the instruction INT n. Its ISR address is obtained by the microprocessor
fromlocation n x 4 in the IVT.
TYPES OF INTERRUPTS
The following image shows the types of interrupts we have in a 8086 microprocessor –
Software Interrupts
These are instructions that are inserted within the program to generate interrupts.
There are 256 software interrupts in 8086 microprocessor.
The instructions are of the format INT type where type ranges from 00 to FF
MICROPROCESSORS AND INTERFACING Page 4
MODULE 3
Some instructions are inserted at the desired position into the program to create interrupts.
These are 2 byte instructions. IP is loaded from type * 04 H and CS is loaded from the next address give by (type *
04) + 02 H. Some important software interrupts are:
Hardware Interrupts
Hardware interrupts are those interrupts which are caused by any peripheral device by sending a signal through a
specified pin to the microprocessor.
There are two hardware interrupts in 8086 microprocessor. They are:
1. NMI
It is a single non-maskable interrupt pin (NMI) having higher priority than the maskable interrupt request pin
(INTR)and it is of type 2 interrupt.
2) INTR
The INTR is a maskable interrupt because the microprocessor will be interrupted only if interrupts are enabled
using setinterrupt flag instruction. It should not be enabled using clear interrupt Flag instruction.
The INTR interrupt is activated by an I/O port. If the interrupt is enabled and NMI is disabled, then the
microprocessor first completes the current execution and sends ‘0’ on INTA pin twice.
The first ‘0’ means INTA informs the external device to get ready and during the second ‘0’ the microprocessor
receives the 8 bit, say X, from the programmable interrupt controller.
Flag register value, CS value of the return address and IP value of the return address are pushed on to the stack.
Priority of interrupt
As far as the Interrupt Priority in 8086 are concerned, software interrupts (All interrupts except single step,
NMI andINTR interrupts) have the highest priority, followed by NMI followed by INTR.
1. Intel 8259 is designed for Intel 8085 and Intel 8086 microprocessor.
2. It can be programmed either in level triggered or in edge triggered interrupt level.
3. We can masked individual bits of interrupt request register.
4. We can increase interrupt handling capability upto 64 interrupt level by cascading further 8259 PIC.
5. Clock cycle is not required.
Vcc and Gnd It is the Power supply and ground pins. +5V power supply isused in this chip.
D7-0 For communication with the processor, there are Eight bi-directional data pins.
RD* It is active low-input pin activated by the processor to read the information status from the 8259.
WR* It is an active low-input pin which is activated by the processor to write the control information
to 8259.
CS* For selecting the chip it is used an active low input pin.
A0 An address input pin used along with RD* and WR* which is used to identify the various
command words.
IR0-IR7 There are Eight asynchronous interrupt request inputs. These interrupt requests can be
programmed for level-trigger or edge-triggered mode.
INT A strong active high-output pin which interrupts the processor. Always connected to the INTR
interrupt input of 8085. The INT output is only activated when all the given conditions are
satisfied correctly.
The Block Diagram consists of 8 blocks which are – Data Bus Buffer, Read/Write Logic, Cascade Buffer
Comparator,Control Logic, Priority Resolver and 3 registers- ISR, IRR, IMR.
1. Databus buffer –
This Block is used as a mediator between 8259 and 8085/8086 microprocessor by acting as a buffer.
It takes the control word from the 8085 (let say) microprocessor and transfer it to the control logic of 8259
microprocessor.
Also, after selection of Interrupt by 8259 microprocessor, it transfer the opcode of the selected Interrupt and address
of the Interrupt service sub routine to the other connected microprocessor.
The data bus buffer consists of 8 bits represented as D0-D7 in the block diagram. Thus, shows that a maximum of
8 bitsdata can be transferred at a time.
2. Read/Write logic
This block works only when the value of pin CS is low (as this pin is active low).
This block is responsible for the flow of data depending upon the inputs of RD and WR.
These two pins are active low pins used for read and write operations.
3. Control logic
It is the centre of the microprocessor and controls the functioning of every block.
It has pin INTR which is connected with other microprocessor for taking interrupt request and pin INT for
giving the output.
If 8259 is enabled, and the other microprocessor Interrupt flag is high then this causes the value of the output
INT pinhigh and in this way 8259 responds to the request made by other microprocessor.
4. Interrupt request register(IRR)
It stores all the interrupt level which are requesting for Interrupt services.
It stores the interrupt level which have to be masked by storing the masking bits of the interrupt level.
7. Priority resolver
It examines all the three registers and set the priority of interrupts and according to the priority of the interrupts,
interruptwith highest priority is set in ISR register.
Also, it reset the interrupt level which is already been serviced in IRR.
8. Cascade buffer
To increase the Interrupt handling capability, we can further cascade more number of pins by using cascade
buffer. So, during increment of interrupt capability, CSA lines are used to control multiple interrupt structure.
9. SP/EN (Slave program/Enable buffer) pin
SP/EN pin is when set to high, works in master mode else in slave mode. In Non Buffered mode, SP/EN pin is
used to specify whether 8259 work as master or slave and in Buffered mode, SP/EN pin is used as an output to
enable data bus.
1) One or more IR lines are raised high that set corresponding IRR bits.
4) Upon receiving an INTA signal from the CPU, the highest priority ISR bit is set and the corresponding IRR bit is
reset The 8259A does not drive data during this period.
5) The 8086 will initiate a second INTA pulse. During this period 8259A releases an 8-bit pointer on to a data bus from
where it is read by the CPU.
6) This completes the interrupt cycle. The ISR bit is reset at the end of the second INTA pulse if automatic end of
interrupt (AEOI) mode is programmed. Otherwise ISR bit remains set until an appropriate EOI command is issued at
the end of interrupt subroutine.
PPI 8255 is a general purpose programmable I/O device designed to interface the CPU with its outside world such as
ADC,DAC, keyboard etc.
It consists of three 8-bit bidirectional I/O ports i.e. PORT A, PORT B and PORT C. We can assign different ports as
input or output functions.
Features of 8255A
The prominent features of 8255A are as follows −
1. 8255 PPI contains 24 programmable I/O pins arranged as 2 8-bit ports & 2 4-bit ports.
2. 8255 PPI contains 3 ports and they are arranged in two groups of 12 pins.
3. It is fully compatible with Intel Microprocessor families.
4. It is also TTL compatible.
5. It has improved DC driving capability.
6. 8255 can operates in 3 modes:
a. Mode 0: Simple I/O.
b. Mode 1: Strobed I/O.
c. Mode 2: Strobed bidirectional I/O
CS A1 A0 SELECTIO
’ N
0 0 0 PORT A
0 0 1 PORT B
0 1 0 PORT C
0 1 1 Control Register
1 X X No Seletion
Modes of operation
There are two different modes of 8255. These modes are:
Bit Set Reset (BSR) Mode
This mode is used to set or reset the bits of the Port-C only. For BSR mode always D7 will be 0. The control
register islooking like this:
In this mode it affects only one bit of Port C at a time. When user set the bit, it remains set until user unset it.
The user needs to load the bit pattern in control register to change the bit.
Bits Function
D6 & D5 These are used to set port A mode. for 00, it is m0 mode, for 01, it is m2
mode and 10 or 11, it is m2 mode.
D3 1 when higher nibble of port C is taking input, and 0 when higher nibble is
sending output.
D0 1 when lower nibble of port C is taking input, and 0 when lower nibble is
sending output.
8279 programmable keyboard/display controller is designed by Intel that interfaces a keyboard with the CPU.
The keyboard first scans the keyboard and identifies if any key has been pressed. It then sends their relative response
of the pressed key to the CPU and vice-a-versa.
The Keyboard can be interfaced either in the interrupt or the polled mode. In the Interrupt mode, the processor is
requestedservice only if any key is pressed, otherwise the CPU will continue with its main task.
In the Polled mode, the CPU periodically reads an internal flag of 8279 to check whether any key is pressed or not
with keypressure.
The keyboard consists of maximum 64 keys, which are interfaced with the CPU by using the key-codes.
These key-codes are de-bounced and stored in an 8-byte FIFO RAM, which can be accessed by the CPU.
If more than 8 characters are entered in the FIFO, then it means more than eight keys are pressed at a time. This is
when the overrun status is set.
If a FIFO contains a valid key entry, then the CPU is interrupted in an interrupt mode else the CPU checks the
status inpolling to read the entry.
Once the CPU reads a key entry, then FIFO is updated, and the key entry is pushed out of the FIFO to generate
space for new entries.
Architecture of 8279
This unit contains registers to store the keyboard, display modes, and other operations as programmed by the
MICROPROCESSORS AND INTERFACING Page 15
MODULE 3
CPU. Thetiming and control unit handles the timings for the operation of the circuit.
c) Scan Counter
In the encoded mode, the counter provides the binary count that is to be externally decoded to provide the scan
lines for the keyboard and display.
In the decoded scan mode, the counter internally decodes the least significant 2 bits and provides a decoded 1
out of 4scan on SL0-SL3.
This unit first scans the key closure row-wise, if found then the keyboard debounce unit debounces the key entry.
In case, the same key is detected, then the code of that key is directly transferred to the sensor RAM along with
SHIFT& CONTROL key status.
This unit acts as 8-byte first-in-first-out (FIFO) RAM where the key code of every pressed key is entered into the
RAMas per their sequence.
The status logic generates an interrupt request after each FIFO read operation till the FIFO gets empty.
In the scanned sensor matrix mode, this unit acts as sensor RAM where its each row is loaded with the status of
their corresponding row of sensors into the matrix.
When the sensor changes its state, the IRQ line changes to high and interrupts the CPU.
This unit consists of display address registers which holds the addresses of the word currently read/written by the
CPUto/from the display RAM.
These are 8 bidirectional data bus lines used to transfer the data to/from the CPU.
b) CLK
The clock input is used to generate internal timings required by the microprocessor.
c) RESET
d) CS Chip Select
When this pin is set to low, it allows read/write operations, else this pin should be set to high.
e) A0
This pin indicates the transfer of command/status information. When it is low, it indicates the transfer of data.
f) RD, WR
This Read/Write pin enables the data buffer to send/receive data over the data bus.
g) IRQ
This interrupt output line goes high when there is data in the FIFO sensor RAM.
The interrupt line goes low with each FIFO RAM read operation. However, if the FIFO RAM further contains
any key- code entry to be read by the CPU, this pin again goes high to generate an interrupt to the CPU.
h) Vss, Vcc
These are the ground and power supply lines of the microprocessor.
i) SL0 − SL3
These are the scan lines used to scan the keyboard matrix and display the digits.
These lines can be programmed as encoded or decoded, using the mode control register.
These are the Return Lines which are connected to one terminal of keys, while the other terminal of the
keys is connected to the decoded scan lines. These lines are set to 0 when any key is pressed.
k) SHIFT
The Shift input line status is stored along with every key code in FIFO in the scanned keyboard mode. Till it is
pulledlow with a key closure, it is pulled up internally to keep it high
In the keyboard mode, this line is used as a control input and stored in FIFO on a key closure.
The line is a strobe line that enters the data into FIFO RAM, in the strobed input mode.
It has an internal pull up. The line is pulled down with a key closure.
m) BD
It stands for blank display. It is used to blank the display during digit switching.
These are the output ports for two 16x4 or one 16x8 internal display refresh registers.
The data from these lines is synchronized with the scan lines to scan the display and the keyboard.
a) Input Mode
This mode deals with the input given by the keyboard and this mode is further classified into 3 modes.
Scanned Keyboard Mode − In this mode, the key matrix can be interfaced using either encoded or decoded
scans. Inthe encoded scan, an 8×8 keyboard or in the decoded scan, a 4×8 keyboard can be interfaced. The code
of key pressedwith SHIFT and CONTROL status is stored into the FIFO RAM.
Scanned Sensor Matrix − In this mode, a sensor array can be interfaced with the processor using either encoder
or decoder scans. In the encoder scan, 8×8 sensor matrix or with decoder scan 4×8 sensor matrix can be
interfaced.
b) Output Mode
This mode deals with display-related operations. This mode is further classified into two output modes.
Display Scan − This mode allows 8/16 character multiplexed displays to be organized as dual 4-bit/single
8-bitdisplay units.
Display Entry − This mode allows the data to be entered for display either from the right side/left side.