1 © Unitec New Zealand Interrupt Lecture 6 Date: - 20 Sept, 2011 Embedded Hardware ETEC 6416.

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

I/O Unit.
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Eng. Husam Alzaq The Islamic Uni. Of Gaza
LOGO Chapter 1 Interrupt handling. hardware interrupt Under x86, hardware interrupts are called IRQ's. When the CPU receives an interrupt, it stops whatever.
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.
The 8051 Microcontroller and Embedded Systems
INTERRUPTS PROGRAMMING
1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.
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:
Embedded Systems 7763B Mt Druitt College of TAFE
Introduction to Embedded Systems
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.
DAT2343 Accessing Services Through Interrupts © Alan T. Pinck / Algonquin College; 2003.
MICROPROCESSOR INPUT/OUTPUT
CoE3DJ4 Digital Systems Design Chapter 6: Interrupts.
Digital to Analogue Converter
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.
Prepared by Eng. Musa Alyaman1 Chapter Seven Chapter Seven PIC16F87x.
The Functions of Operating Systems Interrupts. Learning Objectives Explain how interrupts are used to obtain processor time. Explain how processing of.
Interrupt.
I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU.
Microprocessors 1 MCS-51 Interrupts.
Interrupts Useful in dealing with: The interface: Random processes;
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
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.
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.
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.
Interrupts Microprocessor and Interfacing
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.
بسم الله الرحمن الرحيم MEMORY AND I/O.
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.
Lecture – 8 Interrupt 1. Outline Introduction Handling interrupt Interrupt sources Switching interrupt Peripheral interrupts Using two interrupts Conclusions.
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.
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
The process starts from the I/O device
Timer and Interrupts.
UNIT – Microcontroller.
Interrupts In 8085 and 8086.
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
Interrupt Source: under
Interrupt.
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.
Subject Name: Microprocessors Subject Code:10EC46 Department: Electronics and Communication Date: /20/2018.
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.
Processor Fundamentals
Interrupt Source: under
Lecture 9: TI MSP430 Interrupts & Low Power Modes
Interrupts.
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Interrupt Source: under
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
PIC18 Interrupt Programming
COMP3221: Microprocessors and Embedded Systems
PIC18 Interrupt Programming
Presentation transcript:

1 © Unitec New Zealand Interrupt Lecture 6 Date: - 20 Sept, 2011 Embedded Hardware ETEC 6416

Two methods are used in microcontrollers to acquired external/internal information –Polling: - the microcontroller accesses the external/internal device at the exact time interval and gets the required information. The user is the one who determines the time intervals in which micro “contacts” the device. –Draw back of polling system is that micro wastes it time for the information to arrive. –Interrupt: - Interrupt is the signal sent to the micro to mark the event that requires immediate attention. 2 © Unitec New Zealand

Interrupt Request An interrupt request is an internal or external event that when serviced makes the microcontroller interrupt the execution of the current program and execute another program instead. Once the interrupt is serviced then the main program is executed. 3 © Unitec New Zealand

Sources of Interrupt Internal interrupts :- –I/O module –Memory –CPU External interrupts –External interrupt originates in peripherals and reach the microcontroller through one of its pins and associated ports. 4 © Unitec New Zealand

Resources for servicing of interrupts Each interrupt source has two associated bits. These bits may be in the same register or different registers One bit is a control bit, which enable and disable the interrupt of the source. The other bit is a flag, which is informative that interrupt is occurred. This bit can be checked by the program depending on the technique used to service the interrupt. Microcontrollers also have one bit for global control of interrupts. This must be enabled for any interrupt to be serviced. 5 © Unitec New Zealand

Interrupts type Mask-able interrupts –The control bits used to allow or disallow interrupt requests to reach the CPU. These bits are called mask bits. It is enabled or disabled by software. Non maskable interrupts –It has no masking bits and it can not be enabled or disabled from software. They are always enabled. 6 © Unitec New Zealand

Servicing Interrupt requests Servicing an interrupt request means to interrupt the execution of the current program and to move it to execute another program. Interrupt request servicing is different than normal subroutine as interrupt can occurred any time. 7 © Unitec New Zealand

Steps to service an interrupt request are 1.Microcontroller completes the execution of the current instruction. 2.The PC value is stored in the stack in order to execute the current program, once Microcontroller get back from the interrupt request. 3.Address of interrupt service subroutine is stored in the PC and program is executed at that address. 4.The interrupt service subroutine is executed and finishes with a return instruction. 5.When executing the return instruction, the microcontroller continues executing the program that was interrupted. 8 © Unitec New Zealand

Fixed and vectored interrupts Two ways to provide the CPU with the address for the interrupt service subroutine: 1.The interrupt service subroutine is stored in a fixed memory location that the CPU already knows called FIXED INTERRUPT request. 2.At the time of the interrupt being requested, the interrupt service subroutine address is given to the CPU called VECTORED INTERRUPT. 9 © Unitec New Zealand

Interrupts in PIC microcontrollers Interrupts in medium-end PIC microcontrollers are fixed, maskable interrupts. Interrupts can be disable or enabled globally and locally. For interrupt to be serviced both global and individual interrupts should be enabled. GIE (Global Interrupt Enable) bit is used for enabling the interrupts globally and it is INTCON special function register. 10 © Unitec New Zealand

Interrupts in PIC. Pic micro’s are fixed interrupts. Therefore, when an interrupt is serviced, the microcontroller execute instruction stored at address 4 in the program memory. Source of interrupt can be find out by reading the special function registers (INTCON, PIR1 and PIR2) associated with the interrupt system in PIC’s. 11 © Unitec New Zealand

When interrupt occurs then PIC completes the current instruction, stores the next instruction address in the stack and jumps to address 4 in program memory. The time elapsed between the moment the interrupt is requested and execution of the first interrupt in the interrupt service subroutine is in range of 3 to 3.75 machine cycles and is called latency time. When an interrupt request is being serviced, the global interrupt system is disabled (bit GIE set to 0). In C language, a special function take cares for all this… given in tutorial 12 © Unitec New Zealand

Possible interrupt request in PIC External Interrupt RA2/INT TMR0 Overflow Interrupt PORTA/PORTB Change Interrupts 2 Comparator Interrupts A/D Interrupt Timer1 Overflow Interrupt Timer2 Match Interrupt EEPROM Data Write Interrupt Fail-Safe Clock Monitor Interrupt Enhanced CCP Interrupt EUSART Receive and Transmit interrupts 13 © Unitec New Zealand

Special function registers for Interrupts The following interrupt flags are contained in the INTCON register: –INT Pin Interrupt –PORTA/PORTB Change Interrupts –TMR0 Overflow Interrupt The peripheral interrupt flags are contained in the PIR1 and PIR2 registers. The corresponding interrupt enable bits are contained in PIE1 and PIE2 registers. 14 © Unitec New Zealand

15 © Unitec New Zealand Pic16f877a data sheet pg 24

16 © Unitec New Zealand Pic16f877a data sheet pg 25

17 © Unitec New Zealand Pic16f877a data sheet pp26

PIR1 Interrupt flags The following interrupt flags are contained in the PIR1 register: –A/D Interrupt –EUSART Receive and Transmit Interrupts –Timer1 Overflow Interrupt –Synchronous Serial Port (SSP) Interrupt –Enhanced CCP1 Interrupt –Timer1 Overflow Interrupt –Timer2 Match Interrupt 18 © Unitec New Zealand

19 © Unitec New Zealand Pic16f877a data sheet pp 27

PIR2 flags The following interrupt flags are contained in the PIR2 register: –Fail-Safe Clock Monitor Interrupt –2 Comparator Interrupts –EEPROM Data Write Interrupt 20 © Unitec New Zealand

21 © Unitec New Zealand Pic16f877a data sheet pp 28

Interrupt service subroutine structure As interrupt can occurred any time, so the contents of the most commonly used register should be stored as during execution of interrupt service routine, every thing will be lost. PUSH and POP instructions are used in microprocessor for saving the contents of the registers in stack. PIC can only store the contents of PC in stack In PIC, contents of WORKING and STATUS register should be stored in the stack. This can be done in software by the programmer. 22 © Unitec New Zealand

Steps involved in servicing interrupt request 1.Microcontroller completes the execution of current instruction. 2.Value of PC is stored in the stack. 3.PC is set to 0004 and it causes MC to jump to interrupt routine. 4.Values of W and STATUS registers are stored. 5.Interrupt source are determined by checking the appropriate flag bits. 6.Once the source is identified, its flag is set to 0. 7.After execution of interrupt subroutine, W and STATUS registers are restored. 8.Retfie is used to return to the main program. This retrieves the value of PC from stack and Global Interrupt system (GIE=1) is enabled 23 © Unitec New Zealand