Sunteți pe pagina 1din 28

3/20/2014

Interrupts
Interrupt is a process where an
external device can get the
attention of the microprocessor
1 EEE/DSDCA/SV
2 3/20/2014

An interrupt is considered to be an emergency


signal that may be serviced.
The Microprocessor may respond to it as soon as
possible.

What happens when MP is interrupted ?


When the Microprocessor receives an interrupt signal,
it suspends the currently executing program
Saves PC on to stack(saving registers)
jumps to an Interrupt Service Routine (ISR) to
respond to the incoming interrupt.
Each interrupt will most probably have its own ISR.
EEE/DSDCA/SV
3 3/20/2014

Interrupt
Event inside a computer system requiring some
urgent action by the CPU
CPU suspends the current program execution
Saves PC on to stack(saving registers)
branches to ISR(interrupt service routine)
CPU returns to the main program

EEE/DSDCA/SV
4 3/20/2014

EEE/DSDCA/SV
5 3/20/2014

Interrupt types
External interrupts
Internal interrupts/traps
Software interrupts

EEE/DSDCA/SV
6 3/20/2014

1.External interrupts
Initiatedthrough computers interrupt pins by
external devices
ADC

Two types
Maskable
Non maskable

EEE/DSDCA/SV
7 3/20/2014

Maskable interrupt:
Enabled or disabled by executing instructions like El
or DI

If interrupt is Disabled- ignores interrupt


If interrupt is enabled does not ignore interrupt

EI IE flag

Selectively masking certain interrupts

Eg:
Intel 8086
DI IE flag = 1,no maskable interrupt
EEE/DSDCA/SV
DI IE flag = 0 , maskable interrupt
8 3/20/2014

Non maskable interrupt


Raised for a cause that needs urgent attention
of the CPU
Eg:
hardware error
Power fail interrupt

EEE/DSDCA/SV
9 3/20/2014

2. Internal interrupts
Activated internally by exceptional conditions
such as overflow, division by zero or execution
of an illegal op-code

EEE/DSDCA/SV
10 3/20/2014

3.Software interrupts
Software interrupt is created by the program
So that the CPU can temporarily branch from
the current program to another program.

EEE/DSDCA/SV
11 3/20/2014

Interrupt priorities
processor provided with one or more interrupt
pins on the chip.

mechanism to handle interrupts from several


devices that share one of these interrupt lines .

two ways of servicing multiple interrupts:


polled -SOFTWARE
daisy chain techniques - HARDWARE
EEE/DSDCA/SV
12 3/20/2014

Polled interrupt

EEE/DSDCA/SV
13 3/20/2014

EEE/DSDCA/SV
14 3/20/2014

Polled interrupts handled by software

Slower compared with daisy chaining

Processor responds to an interrupt by executing one general service


routine for all devices

Priorities of devices are determined by the order in which the


routine polls each device

Processor checks the status of each device in the general service


routine for the device

For large number of devices the time required to poll each device
may exceed the time required to service the device

In such case , daisy chain mechanism is used


EEE/DSDCA/SV
15 3/20/2014

example
Several external devices are connected to a
single interrupt line of the processor via OR
gate

When one or more devices activate the INT


line HIGH, the processor pushes the program
counter & possibly some other registers into
stack

Itthen branches to an address defined by


manufacturer of the processor
EEE/DSDCA/SV
16 3/20/2014

The user can write a program at this address to


poll each device,

Starting with the highest priority device, to


find the source of the interrupt

EEE/DSDCA/SV
17 3/20/2014

Assume that device 1 and device 2 are provided


with the start pulse by the processor at nearly
the same time

Suppose that the user assigns device 2 with the


higher priority

The user then sets up this priority mechanism


in the general service routine

EEE/DSDCA/SV
18 3/20/2014

For example the busy signal from device 1 and


or 2 become HIGH, the processor is interrupted

Process pushes PC onto stack

Loads PC with IAR

EEE/DSDCA/SV
19 3/20/2014

General ISR written at this address determines


the source of the interrupt

A 1 is sent to PA1 for device 2( high priority


device).If this device has generated interrupt,
the output PB1 of AND gate becomes high

Ifoutput of AND gate =0,the processor sends a


HIGH to PA0 & checks the output PB0 for
HIGH

EEE/DSDCA/SV
20 3/20/2014

Once the source of interrupt is determined , the


processor can be programmed to jump to the
service routine for that device

The service routine enables the device ,& inputs


the converters outputs to the processor

EEE/DSDCA/SV
21 3/20/2014

Device N and associated logic for


polled-interrupt

EEE/DSDCA/SV
22 3/20/2014

Daisy chain interrupt

EEE/DSDCA/SV
23 3/20/2014

Devices connected in a daisy chain fashion, to


set up priority systems

Suppose one or more devices interrupt the


processor , in response the processor pushes PC
and generates an interrupt acknowledge
signal to highest priority device

EEE/DSDCA/SV
24 3/20/2014

If the device has generated the interrupt , it will


accept the signal ,otherwise it will pass
onto next device until is accepted

Once accepted , the device provides a means for the


processor to find the interrupt address vector by
using external hardware

Priority from hardware connection- hardware


interrupt
EEE/DSDCA/SV
25 3/20/2014

Each device and the Associated logic in


a daisy chain

EEE/DSDCA/SV
26 3/20/2014

Assume device 1 & device 2

Send start signals from processor to device1 & 2


nearly at same time

When busy signal = high


processor interrupted through INT line

EEE/DSDCA/SV
27 3/20/2014

Processor pushes the PC

It then generates a LOW at the for the


highest priority device

Device 1 has the highest priority

BUSY HIGH
Output of AND gate HIGH
low

EEE/DSDCA/SV
28 3/20/2014

This signal enable externalhardware to provide


the interrupt address vector on the processors
data lines

The processor then branches to the service


routine

This program enables the device and inputs the


device output to processor via port B

If
device 1 does not generate BUSY high output of
AND gate becomes low
EEE/DSDCA/SV

S-ar putea să vă placă și