Microprocessors, Programming & Interfacing: Dr. Anita Agrawal

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 0

MICROPROCESSORS, PROGRAMMING &

INTERFACING
(ES C263)
BITS PILANI K.K. BIRLA GOA CAMPUS
Dr. Anita Agrawal
Lecture 20
Interrupts
The dictionary meaning of interrupt is to
breakthesequenceof anyoperation.
Interruptsprovideanefficient waytohandle
unanticipatedevents.
3/13/2011 Anita Agrawal ES C263
3
What is an interrupt?
While the CPU is executing a program, an
interrupt breaks the normal sequence of
execution of instructions, diverts its
execution to some other program(ISP),
executes theinstructions there and on IRET
continues executing the main programfrom
thepoint whereit wasinterrupted.
3/13/2011 Anita Agrawal ES C263
4
Interrupts are useful when interfacing I/O
devices at relatively low data transfer rates,
suchaskeyboardinputs.
The use of interrupts will synchronize the
speedof thetwo.
3/13/2011 Anita Agrawal ES C263
5
Why interrupt?
Q: At home, howdoyouknowwhensomeone
wantstotalktoyouonthetelephone?
A. Periodically pick up the phone and see if
someonesthere.
.Polling.
B. Wait for thephoneto ring and then answer
it
interrupt-driven.
3/13/2011 Anita Agrawal ES C263
6
3/13/2011 Anita Agrawal ES C263
7
Simple
No surprises
Processor in full control
Polling wastes lots of time
Polling Advantages & Disadvantages
CPU onlybotheredwhenactuallyneeded
Canoccur at surprisingor inconvenient times
Havetosaveandrestorestate
3/13/2011 Anita Agrawal ES C263
8
Interrupt Driven
3/13/2011 Anita Agrawal ES C263
9
Interrupt processing allows the processor to
execute other software while the keyboard
operator isthinkingabout what totypenext.
Whenakey is pressed, thekeyboardencoder
debounces theswitch and puts out onepulse
that interruptsthemicroprocessor.
Example of interrupt driven data
transfer (Interrupt Processing)
3/13/2011 Anita Agrawal ES C263
10
A time line shows typing on a keyboard,
aprinter removing datafrommemory, and a
programexecuting
The keyboard Interrupt Service Procedure,
called by the keyboard interrupt, and the
printer interrupt service procedure each take
littletimetoexecute
3/13/2011 Anita Agrawal ES C263
11
By aninterrupt onexternal pins INTR or NMI.
Thisiscalledahardwareinterrupt
Due to an exceptional happening during an
instruction execution, such as division of a
number by zero (generally termed as
exceptionor TRAP incomputer technology).
Duetotheexecutionof anInterrupt instruction
like INT 21h. Thisiscalledsoftwareinterrupt
3/13/2011 Anita Agrawal ES C263
12
Different ways of interrupting
3/13/2011 Anita Agrawal ES C263
13
Intel processors include two hardware pins
(INTR andNMI) that request interrupts
Andonehardwarepin(INTA) to acknowledge
theinterrupt requestedthroughINTR.
Theprocessor also has softwareinterrupts INT,
INTOandINT 3
IRETDinthe80386, 80486, or Pentium
3/13/2011 Anita Agrawal ES C263
14
Interrupt vectors andthevector tablearecrucial to
an understanding of hardware and software
interrupts.
The interrupt vector table is located in
the first 1024 bytes of memory at addresses
000000H0003FFH.
contains256different four-byteinterrupt vectors
An interrupt vector contains the address (segment
andoffset) of theinterrupt serviceprocedure.
3/13/2011 Anita Agrawal ES C263
15
Intel reservesthefirst 32interrupt vectors
Thelowest fiveinterrupt vectorsareidentical
inall Intel processors
Thelast 224vectorsareuser-available
Each is four bytes long in real mode and
contains the starting address of the interrupt
serviceprocedure
Thefirst twobytescontaintheoffset address
Thelast twocontainthesegment address
3/13/2011 Anita Agrawal ES C263
16
3/13/2011 Anita Agrawal ES C263
17
Type 0
The divide error whenever the result from a
division overflowsor an attempt is made to
divide by zero.
Type 1
Single-step or trap occurs after execution of
each instruction if the trap (TF) flag bit is set.
Upon accepting this interrupt, TF bit is cleared
so the interrupt service procedure executes at
full speed.
Type 2
The non-maskableinterrupt occurs when a logic
1 is placed on the NMI input pin to the uP.
non-maskable: it cannot bedisabled
3/13/2011 Anita Agrawal ES C263
18

You might also like