Chapter 10 Interrupts. Basic Concepts in Interrupts  An interrupt is a communication process set up in a microprocessor or microcontroller in which:

Slides:



Advertisements
Similar presentations
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
Advertisements

8085 Interrupts LAKSHMI.B.E.1. Interrupts  Interrupt is a process where an external device can get the attention of the microprocessor. ◦ The process.
I/O Unit.
CSCI 4717/5717 Computer Architecture
68HC11 Polling and Interrupts
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Microcontroller Architecture— PIC18F Family
INTERRUPTS PROGRAMMING
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
MICROPROCESSOR INPUT/OUTPUT
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
Prepared by Eng. Musa Alyaman1 Chapter Seven Chapter Seven PIC16F87x.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose  This training course provides an overview of the CPU architecture.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
1 © Unitec New Zealand Interrupt Lecture 6 Date: - 20 Sept, 2011 Embedded Hardware ETEC 6416.
Teachers Name : Suman Sarker Telecommunication Technology Subject Name : Microcontroller & Embedded System Subject Code : 6871 Semester : 7th Department.
Interrupts  An interrupt is any service request that causes the CPU to stop its current execution stream and to execute an instruction stream that services.
MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.
بسم الله الرحمن الرحيم MEMORY AND I/O.
The 8085 Microprocessor Architecture. What 8085 meant for? 80 - year of invention bit processor 5 - uses +5V for power.
Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB 1228
CS-280 Dr. Mark L. Hornick 1 Sequential Execution Normally, CPU sequentially executes instructions in a program Subroutine calls are synchronous to the.
Interrupts ELEC 330 Digital Systems Engineering Dr. Ron Hayne
Interrupts ELEC 330 Digital Systems Engineering Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Lecture – 8 Interrupt 1. Outline Introduction Handling interrupt Interrupt sources Switching interrupt Peripheral interrupts Using two interrupts Conclusions.
An Introduction to Embedded Systems, and the PIC Microcontroller Lecture 8: Interrupts The aims of this session are to explore the structure and application.
Unit Microprocessor.
An Interrupt is either a Hardware generated CALL (externally derived from a hardware signal) OR A Software-generated CALL (internally derived from.
COURSE OUTCOMES OF Microprocessor and programming
8085 Interrupts LAKSHMI.B.E..
MICROPROCESSOR BASED SYSTEM DESIGN
Microprocessor and Assembly Language
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
The process starts from the I/O device
Microprocessors and Programming Department of Mechatronics Engineering
Introduction An interrupt is an event which informs the CPU that its service (action) is needed. Sources of interrupts: Internal fault (e.g.. divide by.
UNIT – Microcontroller.
Computer Architecture
Interrupts In 8085 and 8086.
Interrupts.
Introduction of microprocessor
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
Dr. Michael Nasief Lecture 2
Interrupt.
8259 Chip The Intel 8259 is a family of Programmable Interrupt Controllers (PIC) designed and developed for use with the Intel 8085 and Intel 8086 microprocessors.
8253 Timer In software programming of 8085, it has been shown that a delay subroutine can be programmed to introduce a predefined time delay. The delay.
An Introduction to Microprocessor Architecture using intel 8085 as a classic processor
* * * * * * * 8051 Interrupts Programming.
8255.
Subject Name: Microprocessors Subject Code:10EC46 Department: Electronics and Communication Date: /20/2018.
Computer System Overview
Interrupts Interrupt is a process where an external device can get the attention of the microprocessor. The process starts from the I/O device The process.
11.1 Interrupt Mechanism, Type, and Priority
8259 Programmable Interrupt Controller
COMPUTER PERIPHERALS AND INTERFACES
Interrupts.
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Interrupts 1/18/2019.
CNET 315 Microprocessor & Assembly Language
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
PIC18 Interrupt Programming
Computer System Overview
COMP3221: Microprocessors and Embedded Systems
Figure Simplified View of Interrupts (default for power-on reset)
PIC18 Interrupt Programming
Microprocessors and Programming Department of Mechatronics Engineering
Presentation transcript:

Chapter 10 Interrupts

Basic Concepts in Interrupts  An interrupt is a communication process set up in a microprocessor or microcontroller in which: An internal or external device requests the MPU to stop the processing The MPU acknowledges the request Attends to the request Goes back to processing where it was interrupted

Types of Interrupts (1 of 2)  Hardware interrupts Maskable: can be masked or disabled Two groups: external and internal interrupts Non-maskable: cannot be disabled  Software interrupts: generally used when the situation requires stop processing and start all over Examples: divide by zero or stack overflow Generally, microcontrollers do not include software interrupts

Example of an Interrupt Circuit How many INTs? Where are they? Page 46 PIC18F4X2

MPU Response to Interrupts (1 of 2)  When the interrupt process is enabled, the MPU, during execution, checks the interrupt request flag just before the end of each instruction.  If the interrupt request is present, the MPU: Completes the execution of the instruction Resets the interrupt flag Saves the address of the program counter on the stack  Some interrupt processes also save contents of MPU registers on the stack. Stops the execution

MPU Response to Interrupts (2 of 2)  To restart the execution, the MPU needs to be redirected to the memory location where the interrupt request can be met. “What to do if you receive the interrupt!” Accomplished by interrupt vectors  The set of instructions written to meet the request (or to accomplish the task) is called an interrupt service routine (ISR).  Once the request is accomplished, the MPU should find its way back to the instruction, next memory location where it was interrupted. Accomplished by a specific return instruction

Interrupt Vectors  Direct the MPU to the location where the interrupt request is accomplished.  They are: Defined memory location where a specific memory location/s is assigned to the interrupt request Defined vector location where specific memory locations assigned to store the vector addresses of the ISRs Specified by external hardware: The interrupt vector address (or a part of it) is provided through external hardware using an interrupt acknowledge signal.

Interrupt Service Routine (ISR)  A group of instructions that accomplishes the task requested by the interrupting source  Similar to a subroutine except that the ISR must be terminated in a Return instruction specially designed for interrupts The Return instruction, when executed, finds the return address on the stack and redirects the program execution where the program was interrupted. Some Return instructions are designed to retrieve the contents of MPU registers if saved as a part of the interrupts.

Reset as a Special Purpose Interrupt  Reset is an external signal that enables the processor to begin execution or interrupts the processor if the processor is executing instructions.  There are at least two types of resets in microcontroller- based systems. Power-on reset and manual reset  When the reset signal is activated, it establishes or reestablishes the initial conditions of the processor and directs the processor to a specific starting memory location.

PIC18 Interrupts  PIC18 Microcontroller family Has multiple sources that can send interrupt requests Does not have any non-maskable or software interrupts; all interrupts are maskable Has a priority scheme divided into two groups  High priority and low priority Uses many Special Function Registers (SFRs) to implement the interrupt process

PIC18 Interrupt Sources (1 of 4)  Divided into two groups External sources and internal peripheral sources on the MCU chip  External sources Three pins of PORTB -RB0/INTO, RB1/INT1,and RB2/INT2 These pins can be used to connect external interrupting sources such as keyboards or switches Change in logic levels of pins RB4-RB7 of PORTB can be recognized as interrupts

PIC18 Interrupt Sources (2 of 4)  Internal peripheral sources Examples: Timers, A/D Converter, Serial I/O, and Low- Voltage Detection Module  SFRs Used to setup the interrupt process:  RCONRegister Control  INTCONInterrupt Control  IINTCON2Interrupt Control2  INTCON3 Interrupt Control3  PIR1 and PIR2Peripheral Interrupt Register1 & 2  PIE1 and PIE2Peripheral Interrupt Enable 1 & 2  IPR1 and IPR2Interrupt Priority Register 1 & 2

PIC18 Interrupt Sources (3 of 4)  RCON register sets up global priority.  INTERCON registers deal primarily with external interrupt sources.  PIR, PIE, and IPR handle internal peripheral interrupts.

Interrupt Priorities and RCON Register (1 of 2)  Any interrupt can be set up as high-priority or low-priority. All high-priority interrupts are directed to the interrupt vector location H. All low-priority interrupts are directed to the interrupt vector location H. A high-priority interrupt can interrupt a low- priority interrupt in progress.

Interrupt Priorities and RCON Register (2 of 2)  The interrupt priority feature is enabled by Bit7 (IPEN) in RCON register.

External Interrupts and INTCON Registers (1 of 3)  Figure 10-4 (a),(b),and (c) shows three registers with interrupt bit specifications primarily for external interrupt sources.  Some bits are used for internal peripherals such as Timer0.

External Interrupts and INTCON Registers (2 of 3)  INTERCON Register Figure 10-4 (a)

External Interrupts and INTCON Registers (3 of 3)  INTCON2 Register  INTCON3 Register Figure 10-4 (b) Figure 10-4 (c)

Example” REG1EQU0x01;Define Register1 ORG0x00 GOTOMAIN ORG0x0008;High Priority Interrupt Vector GOTOINT1_ISR;Go to ISR MAIN:BSFRCON, IPEN;Enable priority -RCON BSFNTCON, GIEH;Enable high-priority -INTCON BCFINTCON2, INTEDG1;Interrupt on falling edge-INTCON2 BSFINTCON3, INT1IP;Set high priority for INT1-INTCON3 BSFINTCON3, INT1IE;Enable Interrupt1- INTCON3 MOVLWD'10';Set up REG1 to count 10 MOVWFREG1,0 ORG0x100 INT1_ISR DECFREG1,1,0 BNZGOBACK MOVLWD'10' MOVWFREG1,0 GOBACK:RETFIEFAST END

Interrupt Service Routine (ISR) (1 of 5)  Similar to a subroutine  Attends to the request of an interrupting source  Must be terminated with the instruction RETFIE (Return from Interrupt)  Should save register contents that may be affected by the code in the ISR

Interrupt Service Routine (ISR) (2 of 5)  When an interrupt occurs, the MPU: Completes the instruction being executed Disables global interrupt enable Places the address from the program counter on the stack (the address where the MPU should return after the completion of the ISR)

Interrupt Service Routine (ISR) (3 of 5)  The RETFIE instruction Gets the address from the top of the stack Places it in the program counter Enables the global interrupt enable bit (INTCON ) Retrieves the contents of registers W, BSR, and STATUS in high-priority interrupts

Interrupt Service Routine (ISR) (4 of 5)  RETFIE instruction format RETFIE [s];Return from interrupt: s = 0 or 1  If s =1, the MPU also retrieves the contents of W, BSR, and STATUS register (previously saved) before enabling the global interrupt bit. Format: RETFIE FAST  The same as RETFIE 1 except the formats are different

Interrupt Service Routine (ISR) (5 of 5)  In high-priority interrupts: The contents of W, STATUS, and BSR registers are automatically saved into respective registers, called shadow registers. RETFIE 1 (or RETFIE FAST) retrieves the contents of these registers.  In low-priority interrupts These registers must be saved as a part of an ISR if these registers are affected by the code in the ISR.

Internal Interrupts and Related Registers  The PIC18 MCU includes many internal devices such as the timers and the A/D converter that can interrupt the MPU.  Each interrupt is associated with three bits Priority, interrupt request flag, and enable (similar to the that of external interrupts)  Registers associated with the internal interrupts IPR:Interrupt Priority Register PIR:Peripheral Interrupt Request (Flag) PIE:Peripheral Interrupt Enable

IPR1—Interrupt Priority Register1

PIR1—Peripheral Interrupt Request Register1

PIE1—Peripheral Interrupt Enable Register1

Handling Multiple Interrupt Sources  In PIC18 MCU, all interrupt requests are directed to one of two memory locations: H (high-priority) or (low-priority)  When multiple requests are directed to these locations, the interrupt source must be identified by checking the interrupt flag through software instructions.

PIC18 Resets (1 of 2)  When the reset signal is activated: The MPU goes into a reset state during which the initial conditions are established. The program counter is cleared to which is called the reset vector. The MPU begins the execution of instructions from location

PIC18 Resets (2 of 2)  PIC18 MCU can be reset by external source such as the push-button key, or when power is turned-on, or by various internal sources. Resets categorized as follows:  External Manual Reset Key  Power-on Reset (POR)  Watchdog Timer Reset (WDT)  Programmable Brown-Out Reset (BOR)  RESET and SLEEP Instructions  Stack Full and Underflow Reset

 Manual Reset  RCON (Reset Control) Register

 Interrupt circuit