Sie sind auf Seite 1von 0
MICROPROCESSORS, PROGRAMMING & INTERFACING (ES C263) BITS PILANI K.K. BIRLA GOA CAMPUS Lecture 20 Dr.

MICROPROCESSORS, PROGRAMMING & INTERFACING

(ES C263) BITS PILANI K.K. BIRLA GOA CAMPUS Lecture 20 Dr. Anita Agrawal
(ES C263)
BITS PILANI K.K. BIRLA GOA CAMPUS
Lecture 20
Dr. Anita Agrawal
Interrupts

Interrupts

What is an interrupt? The dictionary meaning of ‘interrupt’ is to break the sequence of

What is an interrupt?

The dictionary meaning of ‘interrupt’ is to break the sequence of any operation.

Interrupts provide an efficient way to handle unanticipated events.

Anita Agrawal

ES C263

3/13/2011

3

While the CPU is executing a program, an ‘interrupt’ breaks the normal sequence of execution

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 the instructions there and on IRET continues executing the main program from the point where it was interrupted.

Anita Agrawal

ES C263

3/13/2011

4

Why interrupt? Interrupts are useful when interfacing I/O devices at relatively low data transfer rates,

Why interrupt?

Interrupts are useful when interfacing I/O devices at relatively low data transfer rates, such as keyboard inputs.

The use of interrupts will synchronize the speed of the two.

Anita Agrawal

ES C263

3/13/2011

5

Q: At home, how do you know when someone wants to talk to you on

Q: At home, how do you know when someone wants to talk to you on the telephone? A. Periodically pick up the phone and see if someone’s there. ……….Polling…. B. Wait for the phone to ring and then answer it ……… interrupt-driven……….

Anita Agrawal

ES C263

3/13/2011

6

Polling Advantages & Disadvantages • Simple • No surprises • Processor in full control Polling

Polling Advantages & Disadvantages

•

Simple

No surprises Processor in full control

Polling wastes lots of time

Anita Agrawal

ES C263

3/13/2011

7

Interrupt Driven CPU only bothered when actually needed Can occur at surprising or inconvenient times

Interrupt Driven

CPU only bothered when actually needed

Can occur at surprising or inconvenient times

Have to save and restore state

Anita Agrawal

ES C263

3/13/2011

8

Example of interrupt driven data transfer (Interrupt Processing) Interrupt processing allows the processor to execute

Example of interrupt driven data transfer (Interrupt Processing)

Interrupt processing allows the processor to execute other software while the keyboard operator is thinking about what to type next.

When a key is pressed, the keyboard encoder debounces the switch and puts out one pulse that interrupts the microprocessor.

Anita Agrawal

ES C263

3/13/2011

9

Anita Agrawal ES C263 3/13/2011 1 0
Anita Agrawal ES C263 3/13/2011 1 0

Anita Agrawal

ES C263

3/13/2011

10

A time line shows typing on a keyboard, a printer removing data from memory, and

A time line shows typing on a keyboard, a printer removing data from memory, and a program executing

The keyboard Interrupt Service Procedure, called by the keyboard interrupt, and the printer interrupt service procedure each take little time to execute

Anita Agrawal

ES C263

3/13/2011

11

Different ways of interrupting By an interrupt on external pins INTR or NMI. This is

Different ways of interrupting

By an interrupt on external pins INTR or NMI. This is called a ‘hardware interrupt Due to an exceptional happening during an instruction execution, such as division of a number by zero (generally termed as exception or TRAPin computer technology). Due to the execution of an Interrupt instruction like INT 21h. This is called ‘software interrupt

Anita Agrawal

ES C263

3/13/2011

12

Intel (INTR and NMI) that request interrupts… And one hardware pin (INTA’) to acknowledge the

Intel

(INTR and NMI) that request interrupts… And one hardware pin (INTA’) to acknowledge the interrupt requested through INTR. The processor also has software interrupts INT, INTO and INT 3

IRETD in the 80386, 80486, or Pentium

pins

include

hardware

processors

two

Anita Agrawal

ES C263

3/13/2011

13

Interrupt vectors and the vector table are crucial to an understanding of hardware and software

Interrupt vectors and the vector table are crucial to an understanding of hardware and software interrupts.

in

The

at addresses

interrupt

1024

vector

table

is

located

the

first

bytes

of

memory

000000H–0003FFH.

contains 256 different four-byte interrupt vectors

An interrupt vector contains the address (segment and offset) of the interrupt service procedure.

Anita Agrawal

ES C263

3/13/2011

14

Anita Agrawal ES C263 3/13/2011 15
Anita Agrawal
ES C263
3/13/2011
15
Intel reserves the first 32 interrupt vectors The lowest five interrupt vectors are identical in

Intel reserves the first 32 interrupt vectors The lowest five interrupt vectors are identical in all Intel processors The last 224 vectors are user-available Each is four bytes long in real mode and contains the starting address of the interrupt service procedure The first two bytes contain the offset address The last two contain the segment address

Anita Agrawal

ES C263

3/13/2011

16

Type 0 The divide error whenever the result from a division overflows or an attempt

Type 0 The divide error whenever the result from a division overflows or 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.

Anita Agrawal

ES C263

3/13/2011

17

Upon accepting this interrupt, TF bit is cleared so the interrupt service procedure executes at

Upon accepting this interrupt, TF bit is cleared so the interrupt service procedure executes at full speed.

Type 2 The non-maskable interrupt occurs when a logic 1 is placed on the NMI input pin to the uP. non-maskable : it cannot be disabled

Anita Agrawal

ES C263

3/13/2011

18