This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Interrupts
Nurudeen Olayiwola
Thomas Gutierrez
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Example
• Non-maskable interrupts
• Conclusion
2
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Question??• When you are at home sitting on your
lazy boy, how do you know when someone wants to talk to you on the phone?
– Do you periodically get up and pick up the phone to see if someone is there?
– Or do you wait till the phone rings to answer it?
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Example
3
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Answer?• The first scenario shows a person
doing what is known as polling.
• The second case illustrates an interrupt-driven person.
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Example
4
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Polling
• AKA “busy waiting”; looping program
• Continues checking status register until a particular state exists
• “Are we there yet? Are we there yet? Are we there yet?”
• What happens if something occurs at other devices while the processor is busy waiting??
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Example
5
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Interrupt
• Device sends a special signal to CPU when data arrives.
• “Wake me up when we get there.”
• Responds to hardware interrupt signal by interrupting current processing.
• Now CPU can perform tasks before and after interrupt instead of just polling!! Good!
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Example
6
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
General Interrupt Flow1. Completes current instruction
2. Saves current state to status registers
3. Identify source
4. Jump to and activate Interrupt Service Routing (ISR)
5. Return to original program (RTI) and restore state
Register
Interrupt drivenCPU
I/Odevice
I/Odevice
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Example
7
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Interrupts: Flow Chart
SOFTWARE
INTERRUPT
STACK MPU REGISTER CONTENTS
SET APPROPRIATE
BIT IN CCR
LOAD INTERRUPT VECTOR INTO
PROGRAM COUNTER
VECTOR TABLE
HARDWARE
INTERRUPT
MASK SET?
N
Y
EXECUTE INTERRUPT SERVICE ROUTINE
$FFC0
$FFFF
CONTINUE MAIN PROGRAM
• General Info
8
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Brief Background
• Univac 1103/1103A (1953-56) – first recognized CPU with interrupts. Current instruction was stored in memory and program counter loaded with a fixed address.
• Other notables:– IBM (1954) – first to use interrupt
masking– NBS DYSEAC (1954) – first with I/O
interrupts
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Example
9
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Purpose/Applications• To modify or do additional instructions based on
internal requests and/or external devices.
• Provide a means for suspending current instructions for more important tasks.
• Hardware (called Interrupts or Resets)– Reset– User-defined interrupt– Timer operations– CPU operations monitor failure
the CPU of the passage of time• Multi-tasking• Updating counters• Timing during interactive programs
• Errors• Interrupts can notify of error situations
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Example
11
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Purpose/Applications (cont.)
• Practical uses/examples
• Change direction of a motor.
• Auto wiper speed increased or decreased.
• Pressing a pause button on a VCR
• HC11 controlled transmission system
• Etc.
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Example
12
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Types of interrupts
• Ignorable interrupts (or Maskable)– Most often used– Good for using when computer needs to
do something more important– When the interrupt mask is set, interrupts
are hidden and therefore are ignored.
• Non-ignorable interrupts (Non-maskable)• NMI’s take precedence and interrupt any
task
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Example
13
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Interrupt Vector Table
• When an interrupt occurs, control of the program moves to the interrupt handling routine– Event similar to subroutine– How do we know where the handler routine is
though??
• The address of the handler is provided by the interrupt vector table– IVT has one entry for each type of interrupt– Each entry is indexed by interrupt type, and
includes a pointer to the handler
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Example
14
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Interrupt Vector TableMaskable when the I-bit of CCR is set
Unmaskable
lowest priority
highest priority
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Example
15
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Maskable/Unmaskable
• 6 Non-Maskable– always interrupt the program
execution• 15 Maskable
– can enable or disable by mask bits– HOW?
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Example
16
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Stacking orderWhen an interrupt occurs:
2. HC11 pushes on stack: PC, accumulators and registers, CCR
3. HC11 sets the I-bit Masks interrupts - can’t interrupt an interrupt
4. Looks up vector of highest-priority interrupt
5. Branches to interrupt service routine Executes until RTI is encountered
6. Restores accumulators and registers, CCR from stack (note: this includes restoring the I-bit of CCR)
7. Returns to instruction after the one that was interrupted (note: other interrupts may be pending now)
1. Finish execution of the current instruction Note: Non-maskable interrupts and resets happen immediately
SP-9
SP-8
SP-7
SP-6
SP-4
SP-5
SP-3
SP-1
SP-2
SP-0
CCR
ACCB
ACCA
IXH
IXL
IYH
IYL
PCH
PCL
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Example
17
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Controlling Interrupts: The I-bit
• Exists as bit 4 in the Condition Code Register (CCR)– When set (I=1), interrupts will be inhibited and
placed as pending– When cleared (I=0), interrupt servicing will be
allowed when asked
• The I bit is always set while servicing an interrupt; Interrupts can’t nest
• Set during RESET to allow minimum system initialization
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Example
18
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Controlling Interrupts: The I-bit
• Can also be set by software to prevent execution of maskable interrupts– SEI (SEt Interrupt Mask)
• Can be cleared by software instructions– CLI (CLear Interrupt Mask)
• Automatically cleared by RTI instruction
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Example
19
• General Info
• Purpose/ Applications
• Interrupt Priority/ IVT
• Controlling Interrupts
• Maskable interrupts
• Non-maskable interrupts
• Example
• Conclusion
Maskable Interrupt: HPRIO
• Can elevate the priority of one of the maskable interrupts.
• Uses bits 0-3 of HPRIO (Highest PRIOrity Interrupt Register)
• Default is IRQ.
• Can be set at anytime during program as long as I bit is set.