Download presentation
Presentation is loading. Please wait.
Published byBrent Chase Modified over 9 years ago
1
ECE 353 Introduction to Microprocessor Systems Michael J. Schulte Week 11
2
Topics Interrupt Concepts 80C188EB Interrupt Handling Hardware Interrupts 80C188EB Interrupt Control Unit (ICU) Interrupt Service Routines (ISRs) Interrupt Driven Systems Software Interrupts and Exceptions Interrupt Priority and Latency Interrupt Controllers Debugging Interrupt Hardware and Software
3
Why Use Interrupts? Maximize processor utilization and efficiency Allow use of sleep/idle states when nothing to do to save power Minimize latency in responding to complex input/output structures Facilitate event driven applications
4
Interrupt Primer Terminology Event – an occurrence that the processor must respond to Asynchronous events – events that occur at unpredictable times while program is running Pending interrupt – an IRQ signal has been received, but it has not been serviced yet. Interrupt Service Routine (ISr) – the code executed in response to an IRQ signal. Interrupt-driven I/O – I/O devices that use interrupts to signal when they require service Critical code section – a section of code that cannot be interrupted
5
Basic Interrupt Hardware
6
Types of Interrupts Maskable interrupt – an interrupt that can be disabled when desired Nonmaskable interrupt (NMI) – an interrupt that cannot be disabled. Level-sensitive interrupts – an interrupt request is said to exist whenever the IRQ signal is at the designated level Edge-sensitive interrupts – an interrupt is only recognized on the signal’s transition
7
Multiple Interrupt Sources Multiple interrupt sources handled by Polled interrupts - single ISR is invoked for all interrupts and ISR must check all the possible interrupt sources Vectored interrupts - each interrupt source is associated with a unique ISR and the processor hardware selects the correct ISR The starting address of the ISR is obtained from a look-up table (vector table) Interrupt processing begins at a fixed, unique location based on the interrupt source
8
Multiple Interrupt Structure
9
Interrupt Priority Priority schemes determine the order in which interrupts are serviced
10
Software Interrupts & Exceptions Software interrupts provide another mechanism for changing control flow Interrupt instructions – Often used by applications to communicate with OS x86 features the INT instruction Exceptions – software interrupts that are invoked by some unusual condition Division by zero Page fault
11
80C188EB Interrupts
12
Interrupt Processing Sequence
13
Saved and Restored State State saved on interrupt Save restored with RETI
14
Interrupt Vector Table Each interrupt is identified by an 8-bit type code The interrupt vector table contain 256 32-bit ISR starting addresses (IP, CS) Starts at 00000h Not relocatable in the 80C188 1024 bytes long (1KB) Structure
15
Initializing Interrupt Vectors movdi, INT_TYPE * 4 cli push ds xorax, ax movds, ax;segment 0000h movax, offset ISR_X mov[di], ax;load offset movax, seg ISR_X mov[di+2], ax;load segment popds sti
16
80C1888EB Hardware Interrupts Modular core interrupts INTR – Generated by ICU Interrupt Enable Flag (IF) STI / CLI NMI – Nonmaskable interrupt HALT – Causes CPU to stop Interrupt example Hardware Software (vector table)vector table
17
80C188EB ICU Performs synchronization and prioritization of interrupts to CPU (block diagram)block diagram Functions Masking (IMASK, PRIMSK)IMASKPRIMSK Priorities (TCU/SCU, INT0-1, INT2-4)TCU/SCUINT0-1INT2-4 Default Default Synchronization/prioritization (REQST, INSERV)REQSTINSERV External interrupts (INT0-1, INT2-4)INT0-1INT2-4 Internal interrupts (TCU/SCU, INTSTS)TCU/SCUINTSTS Polling interrupt sources (POLLSTS, POLL)POLLSTSPOLL
18
Interrupt Service Routines ISR prerequisites ISR implementation Context save Clear IRQ FF (if necessary) Allow nesting (if desired) Handle interrupt Clear INSERV bit Context restore IRET EOI register use (EOI)EOI Shared procedures and resources
19
Interrupt Driven Systems Foreground vs. background tasks Events determine order of execution
20
Software Interrupts & Exceptions INT instruction Exceptions Divide error Single-step Breakpoint INTO BOUND Invalid Opcodes ESC
21
Interrupt Priority and Latency Overall priorities and resolution Defaults INTR, NMI, and exceptions Interrupt timing Latency Response time 80C188EB ICU specifics
22
82C59A PIC 82C59A structure and capabilities Can be cascaded IBM PC used two of them to get 15 IRQ lines Now usually part of chip set Prioritization schemes Fixed Rotating Hierarchical Interrupt Acknowledge Bus CyclesBus Cycles Run to get type number of interrupt source 82C59A handles placing data on the bus
23
Interrupt Issues Using periodic interrupts to perform iterative tasks What to do when good interrupts go bad… Software debugging Hardware debugging Real-time issues Inter-process communication (IPC) issues
24
In-Class Assessment Quiz What sort of safeguards might you need to design into NMI hardware? For the 80C188EB, describe what happens between an IRQ being asserted and the actual execution of the ISR. What are the differences between vectored interrupts and polled interrupts?
25
In-Class Assessment Quiz What is a ‘level-sensitive’ interrupt? What problems can arise when using a semaphore to control access to a resource used by the main program and an ISR? What 80C188 instructions help handle this? Draw a flowchart for a periodic (1 KHz) ISR that will be used to generate precise delays. Only a single word variable is to be used to communicate with the ISR.
26
Vector Table
27
Interrupt Example - Hardware
28
IMASK
29
PRIMSK
30
REQST
31
INSERV
32
POLL
33
POLLSTS
34
EOI
35
INTSTS
36
REQST
37
TCUCON, SCUCON
38
I2CON, I3CON, I4CON
39
I0CON, I1CON
40
ICU Latency and Response Time
41
Default Interrupt Priorities Interrupt NamePriority Level Exceptions/NMI1 Timer 02a Timer 12b Timer 22c Serial Receive3a Serial Transmit3b INT44 INT05 INT16 INT27 INT38 Letters indicate relative priority within a level
42
ICU Block Diagram
43
INTA Bus Cycles
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.