




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Dr. Bradley J. BazuinAssociate Professor
Department of Electrical and Computer Engineering
College of Engineering and Applied SciencesCollege of Engineering and Applied Sciences
-^
-^
-^
-^
Interrupt Service Routines
-^
-^
-^
-^
Respond to real time hardware, “software events”, or programsoftware initiated interrupts.
-^
Software errors can cause software interrupts,usually referred to as a trap or a fault
-^
Illegal instruction, illegal memory address,etc.
-^
(advanced memory management page fault or segmentation fault)
SWI is a software interrupt
-^
Transfers program execution to D-Bug
Activated by: software or IRQ pin if enabled or a peripheral devicehardware interrupt if enabled.
-^
Software interrupts happen at defined times in code execution
p^
pp
Hardware interrupts happen at random times during code execution
-^
The reset mechanism establishes these initial conditions for the
-^
The reset mechanism establishes these initial conditions for thecomputer system.
-^
The power-on reset establishes the initial values of registers andI/O control registers.
-^
The manual reset without power-down allows the computer to getout of most error conditions if hardware doesn’t fail.
-^
-^
Examples of interrupts include I/O completion, timer time-out,
p^
p^
p^
illegal opcodes, arithmetic overflow, divide-by-0, etc.
-^
For most PCs, an interrupt is caused by a real-world event or bysomething going wrong.
-^
In most “real-time” signal processing almost all events driveinterrupts and interrupts are prioritized so the most importantinterrupt is worked on first.
-^
External: an external pin or level causes the interrupt
-^
Internal: an internal microcontroller peripheral device or CPU
ti^
th
i t
t
operation causes the interrupt
-^
Software: the swi assembly language instruction
-^
Real-time data sample systems
-^
Power failure
-^
-^
-^
Time-of-Day
-^
Health check and status
-^
Other Periodic Functions
-^
Task Switching for a multitasking operating system
g^
g^
p^
g^
y
-^
CPU time is divided into many short time slots of 10 to 20msMultitasking operating systems assign a program to be executed
-^
Multitasking operating systems assign a program to be executedfor one time slot
-^
At end of a time slot or when program is waiting for thecompletion of an I/O operation the operating system takes overcompletion of an I/O operation, the operating system takes overand assigns another program for execution
-^
-^
-^
Allow multiple pending interrupt requests
-^
Resolve the order of service for multiple pending interrupts
-^
Interrupts that can not be ignored by the CPU are callednonmaskable interrupts. (An NMI is usually the highest priorityinterrupt).
-^
Interrupts that can be ignored by the CPU are called maskableinterrupts.
-^
A maskable interrupt must be enabled before it can interrupt theCPU and must be disabled when it is not allowed to interrupt theCPU.
-^
An interrupt is enabled by setting an enable/disable bit or flag.
-^
Starting address of the interrupt service routine
-^
A table where all interrupt vectors are stored
-^
A table where all interrupt vectors are stored
-^
Predefined locations (Microchip PIC18, 8051 variants)
-^
Fetching the vector from a predefined memory location (HCS12)
-^
Executing an interrupt acknowledge cycle to fetch a vector numberin order to locate the interrupt vector (68000 and x86 families)
p^
-^
Step 1. Initializing the interrupt vector table
-^
Step 2. Writing the interrupt service routineStep 3 Enabling the desired interrupts at the appropriate location
-^
Step 3. Enabling the desired interrupts at the appropriate locationin the system code.
-^
Saving and restoring of CPU status and other registers. (HCS12needs to save all CPU registers).
-^
Execution time of instructions of the interrupt service routine.
-^
Overhead time required to enter and exit an ISR
The execution of the return-from-interrupt (RTI) instruction thatwill restore all the CPU registers.
g
-^
-^
-^
-^
-^
-^
-^
When an interrupt is enabled, the CPU will respond to itWhen an interrupt is disabled the CPU will ignore it
-^
When an interrupt is disabled, the CPU will ignore it
-^
-^
-^
b
b
b
b
b
b
b
b
S^
X^
H^
I^
N^
Z^
V^
C^
-^
-^
i h 1011 1111
;AND CCR with 1011 1111 or $BF
Also needed: interrupt vector and XIRQ ISR
When an XIRQ interrupt occurs after non-maskable interrupts areenabled, both the X bit and the I bit are set automatically to preventother interrupts from being recognized during the interrupt serviceroutine.–
The mask bits are set after the registers are pushed onto the stacked but
-^
The mask bits are set after the registers are pushed onto the stacked, butbefore the interrupt vector is fetched.
-^
Normally, a return-from-interrupt (RTI) instruction at the end of theinterrupt service routine restores register values that were present beforeth
i t
t^
d
the interrupt occurred.
Since the CCR is stacked before the X bit is set, the RTI normallyclears the X bit, and thus re-enables non-maskable interrupts.–
It is possible to manipulate the stacked value of X so that X is set after anIt is possible to manipulate the stacked value of X so that X is set after anRTI, but there is no software method to reset X (and disable XIRQ) onceX has been cleared.