Lecture – 8 Interrupt 1. Outline Introduction Handling interrupt Interrupt sources Switching interrupt Peripheral interrupts Using two interrupts Conclusions.

Slides:



Advertisements
Similar presentations
Interrupts How to do 2 things at the same time. Need for interrupts Computers often have to deal with asynchronous events. That is to say events that.
Advertisements

Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
Interrupts, Low Power Modes and Timer A (Chapters 6 & 8)
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
8051 Core Specification.
I/O Unit.
Eng. Husam Alzaq The Islamic Uni. Of Gaza
6-1 I/O Methods I/O – Transfer of data between memory of the system and the I/O device Most devices operate asynchronously from the CPU Most methods involve.
Basic Input/Output Operations
Chapter 6 Interrupts (I. Scott Mackenzie).
16.317: Microprocessor System Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 29: Microcontroller intro.
The 8051 Microcontroller and Embedded Systems
INTERRUPTS PROGRAMMING
Interrupts. 2 Definition: An electrical signal sent to the CPU (at any time) to alert it to the occurrence of some event that needs its attention Purpose:
COMP201 Computer Systems Exceptions and Interrupts.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
Interrupts, Counter and Timers. Interrupts (1) Interrupt-driven I/O uses the processor’s interrupt system to “interrupt” normal program flow to allow.
MICROPROCESSOR INPUT/OUTPUT
CoE3DJ4 Digital Systems Design Chapter 6: Interrupts.
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
PIC16F877 ISR Points to note Interrupt Triggers –Individual interrupt flag bits are set, regardless of the status of their corresponding mask bit, PEIE.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 part 4 Exceptions.
Interrupt.
Microprocessors 1 MCS-51 Interrupts.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
Chapter 7 Larger Systems and the PIC 16F873A The aims of this chapter are to introduce: The architecture of the 16F873A microcontroller; The 16F873A memory.
1 © Unitec New Zealand Interrupt Lecture 6 Date: - 20 Sept, 2011 Embedded Hardware ETEC 6416.
EEE237 Introduction to Microprocessors Week x. SFRs.
Teachers Name : Suman Sarker Telecommunication Technology Subject Name : Microcontroller & Embedded System Subject Code : 6871 Semester : 7th Department.
1 Interrupts, Resets Today: First Hour: Interrupts –Section 5.2 of Huang’s Textbook –In-class Activity #1 Second Hour: More Interrupts Section 5.2 of Huang’s.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.
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.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
I NTRODUCTION TO PIC PROGRAMMING By : S HERIF H ARHASH.
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
بسم الله الرحمن الرحيم MEMORY AND I/O.
Working with Time: Interrupts, Counters and Timers
Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB 1228
Embedded Computer - Definition When a microcomputer is part of a larger product, it is said to be an embedded computer. The embedded computer retrieves.
Polled IO versus Interrupt Driven IO
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.
The 8051 Microcontroller Chapter 6 INTERRUPTS. 2/29 Interrupt is the occurrence of a condition an event that causes a temporary suspension of a program.
Aum Amriteswaryai Namah:. SUB ROUTINES Instead of repeating same program segments at all locations, they are written and stored separately; Each such.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Chapter 10 Interrupts. Basic Concepts in Interrupts  An interrupt is a communication process set up in a microprocessor or microcontroller in which:
An Introduction to Embedded Systems, and the PIC Microcontroller Lecture 8: Interrupts The aims of this session are to explore the structure and application.
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
Interrupts and exceptions
Microprocessor Systems Design I
UNIT – Microcontroller.
Computer Architecture
Interrupts In 8085 and 8086.
Interrupts, Counter and Timers
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
Interrupt Source: under
Introduction to Micro Controllers & Embedded System Design Interrupt
UNIT 5 TIMRERS/COUNTERS
The PIC uCs PIC Microcontroller and Embedded Systems Muhammad Ali Mazidi, Rolin McKinlay and Danny Causey Eng. Husam Alzaq The Islamic Uni. Of Gaza 11-1.
* * * * * * * 8051 Interrupts Programming.
Interrupt.
Interrupt Source: under
Interrupt Source: under
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
PIC18 Interrupt Programming
Presentation transcript:

Lecture – 8 Interrupt 1

Outline Introduction Handling interrupt Interrupt sources Switching interrupt Peripheral interrupts Using two interrupts Conclusions 2

Interrupts Interrupts are the most used I/O technique for many systems. One problem exists with interrupts the are difficult to troubleshoot. The ISR is the function called by an interrupt. Each interrupting source has three control bits, IF (interrupt flag), IE (interrupt enable), and IP (interrupt priority). The IF flag is set only if an interrupt takes effect and cleared by the program. 3

Handling interrupts (1) The mechanism is very similar to CALL: 1)the present instruction completes. 2)PC (the address of the next instruction) is saved to the hardware stack 3)ISR is called at a fixed (by PlC architecture) address. 4)ISR operates as a subroutine (MUST not corrupt any registers/flags/bank settings/W), return (RETFIE) on completion. 4

Handling interrupts (2) ISR starts at the specific address. PC of the interrupted program is saved by hardware in a hardware stack. STATUS register and any other registers used by ISR are to be saved by the programmer if necessary. ISR should (1) polls status bits of valid interrupt sources; (2) serve requested; (3) clear their request bits. Restore registers and RETIF (programmer). 5

Interrupt sources Direct pin at PORT B (interrupt request) Change of signal at most pins of port B (interrupt on change) Generated by built-in peripherals (e.g., timers on overflow etc) Generated by internal watchdog timer - could be used to recover after a hardware malfunction. Generated when the supply voltage drops below a preset level, or just recover from a power loss. Interrupts can be disabled in general, or any specific interrupt can be disabled. 6

Why interrupt control is required How it is possible to handle more than one interrupt? What will happen if two interrupts occur at the same time? What will happen if an interrupt occurs while the other one is being served ? How to protect a critical code from being intrrupted (e.g. injecting a drug to a patient)? BCF INTCON, GIE critical code BSF INTCON, GIE 7

Interrupt control register Interrupt flag bits get set when an interrupt condition occurs regardless of the state of its corresponding enable bit or the global enable bit, GIE (INTCON ). 8 Enable bitsFlag bits GIE - generalN/A PEIE- peripheral interruptsN/A TMR0IE - timer 0TMR0IF - timer 0 INT0IE - Interrupt request (RB0)INT0IF - interrupt request (RB0) RABIE - interrupt on change port BRABIF - interrupt on change port B

Switching interrupts General IE (GIE) - ensures that the ISR is not interrupted. IE flags - allow to enable particular interrupts ONLY. IF flags : indicate what interrupt actually happened. 9

Example What event has happened? GIEPEIET0IEINTERBIET0IFINTFRBIF

Example What event has happened? GIEPEIET0IEINTERBIET0IFINTFRBIF

Example What event has happened? GIEPEIET0IEINTERBIET0IFINTFRBIF

ISR programming necessities Initialisation: enable required interrupt, set GIE. ISR: Clear the IF associated (if not, the same interrupt will occur straight on RETFIE). ISR: Return using RETFIE. 13

Peripheral interrupts Peripheral interrupts enable register (PIE1) Peripheral interrupts request register (PIR1) EE-EEPROM, A/D converter, EUSART receive buffer, comparator C2, comparator C1, oscillator fail, EUSART transmit buffer, timer 1 overflow. 14

Example PIE1 PIR1 What event has happened? EEIEADIERCIEC2IEC1IEOSFIETXIETMR1IE EEIFADIFRCIFC2IFC1IFOSFIFTXIFTMR1IF

16 Example PIE1 PIR1 What event has happened? EEIEADIERCIEC2IEC1IEOSFIETXIETMR1IE EEIFADIFRCIFC2IFC1IFOSFIFTXIFTMR1IF

Using two interrupts E.g., on change and RC(receive). Initialization of both required BSF INTCON, RBIE BSF PIE1, RCIE BSF INTCON, PEIE BSF INTCON, GIE 17

Summary Interrupts allow putting away some background activities for something more important. Microcontrollers deal with interrupts from free running peripherals and external stimuli. They need to be enabled using lE flags, and the interrupt source can be determined using the IF flags. The ISR is placed at a fixed address. It must not to change anything except its dedicated variables. Interrupts can be prioritised if more than one is enabled. 18