Interrupt.

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

Interrupts Professor Yasser Kadah –
Interrupts, Low Power Modes and Timer A (Chapters 6 & 8)
8051 Core Specification.
I/O Unit.
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Communication Lab - Interrupts 1/13 Sequential Programming  Our C++ programs are sequential ( סדרתיים), they start at the first instruction and end at.
1 Computer System Overview OS-1 Course AA
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.
Chapter 6 Interrupts (I. Scott Mackenzie).
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
The 8051 Microcontroller and Embedded Systems
INTERRUPTS PROGRAMMING
1 Computer System Overview Chapter 1 Review of basic hardware concepts.
Evolution of Microcontroller Firmware Development David Benjamin.
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.
Ch. 9 Interrupt Programming and Real-Time Sysstems From Valvano’s Introduction to Embedded Systems.
Computer System Overview Chapter 1. Operating System Exploits the hardware resources of one or more processors Provides a set of services to system users.
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.
The Functions of Operating Systems Interrupts. Learning Objectives Explain how interrupts are used to obtain processor time. Explain how processing of.
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.
1. Registers Used in Timer/Counter  TH0, TL0, TH1, TL1  TMOD (Timer mode register)  TCON (Timer control register) 2.
Microprocessors 1 MCS-51 Interrupts.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose  This training course provides an overview of the CPU architecture.
Lecture 8 Interrupts. 2  Introduction  Interrupt organization  Interrupt summary  Enabling and disabling interrupts  Interrupt priority  Interrupt.
8051 Micro controller. Architecture of 8051 Features of 8051.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
1 © Unitec New Zealand Interrupt Lecture 6 Date: - 20 Sept, 2011 Embedded Hardware ETEC 6416.
MCS51 - lecture 5. Lecture 5 2/28 Interrupts in MCS51 Step work Power consumption reducing.
Fall 2000M.B. Ibáñez Lecture 25 I/O Systems. Fall 2000M.B. Ibáñez Categories of I/O Devices Human readable –used to communicate with the user –video display.
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.
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.
9/20/6Lecture 3 - Instruction Set - Al1 Exception Handling.
Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB 1228
kashanu.ac.ir Microprocessors Interrupts Lec note 8.
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.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Timer Programming in Assembly and C Prepared By:
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.
INSTITUTE: INSTITUTE:PARUL INSTITUTE OF TECHNOLOGY BRANCH : BRANCH :B.E. E.C.5 TH SEM. SUBJECT:MICROCONTROLLER & INTERFACING TOPIC:AVR INTTRUPT TOPIC:AVR.
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO microcontroller & programming.
Chapter 11 INTERRUPTS PROGRAMMING
Microprocessor Systems Design I
Interrupts In 8085 and 8086.
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
* * * * * * * 8051 Interrupts Programming.
Interrupt.
Processor Fundamentals
Interrupt Source: under
Interrupts.
Interrupt.
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.
Computer System Overview
Interrupts of 8051 Introduction 8051 Interrupt organization
COMP3221: Microprocessors and Embedded Systems
Presentation transcript:

Interrupt

Interrupts of 8051 Introduction 8051 Interrupt organization Processing Interrupts Program Design Using Interrupts Timer Interrupts Serial Port Interrupts External Interrupts Interrupt Timings

Interrupt An interrupt is the occurrence of a condition--an event -- that cause a temporary suspension of a program while the event is serviced by another program (Interrupt Service Routine ISR or Interrupt Handler). Interrupt-Driven System-- gives the illusion of doing many things simultaneously, quick response to events, suitable for real-time control application.

8051 Interrupt Organization 5 interrupt sources: 2 external, 2 timer, a serial port 2 programmable interrupt priority levels fixed interrupt polling sequence can be enabled or disabled IE (A8H), IP (B8H) for controlling interrupts

Enabling and Disabling Interrupts IE (Interrupt Enable Register A8H) Bit Symbol Bit Address Description (1=enable, 0=disable) IE.7 EA AFH Global enable/disable IE.6 - AEH Undefined IE.5 ET2 ADH Enable timer 2 interrupt (8052) IE.4 ES ACH Enable serial port interrupt IE.3 ET1 ABH Enable timer 1 interrupt IE.2 EX1 AAH Enable external 1 interrupt IE.1 ET0 A9H Enable timer 0 interrupt IE.0 EX0 A8H Enable external 0 interrupt Two bits must be set to enable any interrupt: the individual enable bit and global enable bit SETB ET1 SETB EA MOV IE,#10001000B

Interrupt Priority (IP, B8H) Bit Symbol Bit Address Description (1=high, 0=low priority) IP.7 - - Undefined IP.6 - - Undefined IP.5 PT2 BDH Priority for timer 2 interrupt (8052) IP.4 PS BCH Priority for serial port interrupt IP.3 PT1 BBH Priority for timer 1 interrupt IP.2 PX1 BAH Priority for external 1 interrupt IP.1 PT0 B9H Priority for timer 0 interrupt IP.0 PX0 B8H Priority for external 0 interrupt 0= lower priority, 1= higher priority, reset IP=00H Lower priority ISR can be interrupted by a high priority interrupt. A high priority ISR can not be interrupted.

Interrupt Flag Bits Interrupt Flag SFR Register & Bit Position ------------------------------------------------------------------------------ External 0 IE0 TCON.1 External 1 IE1 TCON.3 Timer 1 TF1 TCON.7 Timer 0 TF0 TCON.5 Serial port TI SCON.1 Serial Port RI SCON.0 Timer 2 TF2 T2CON.7 (8052) Timer 2 EXF2 T2CON.6 (8052) The state of all interrupt sources is available through the respective flag bits in the SFRs. If any interrupt is disabled, an interrupt does not occur, but software can still test the interrupt flag.

Polling Sequence If two interrupts of the same priority occur simultaneously, a fixed polling sequence determines which is serviced first. The polling sequence is External 0 > Timer 0 > External 1 > Timer 1 > Serial Port > Timer 2

Program Design Using Interrupts I/O event handling: Polling: main program keeps checking the flag, waiting for the occurrence of the event. Inefficient in some cases. Interrupt-driven: CPU can handle other things without wasting time waiting for the event. Efficient, prompt if ISR is not so complex. Suitable for control application. I/O processor: dedicated processor to handle most of the I/O job without CPU intervention. Best but most expensive

Processing Interrupts When an interrupt occurs and is accepted by the CPU, the main program is interrupted. The following actions occur: The current instruction completes execution. The PC is saved on the stack. The current interrupt status is saved internally. Interrupts are blocked at the level of the interrupt. The PC is loaded with the vector address of the ISR The ISR executes. The ISR finishes with an RETI instruction, which retrieves the old value of PC from the stack and restores the old interrupt status. Execution of the main program continues where it left off.

Interrupt Vectors Interrupt vector = the address of the start of the ISR. When vectoring to an interrupt, the flag causing the interrupt is automatically cleared by hardware. The exception is RI/TI and TF2/EXF2 which should be determined and cleared by software. Interrupt Flag Vector Address System Reset RST 0000H (LJMP 0030H) External 0 IE0 0003H Timer 0 TF0 000BH External 1 IE1 0013H Timer 1 TF1 001BH Serial Port RI or TI 0023H Timer 2 TF2 or EXF2 002BH

8051 Program Design Using Interrupt ORG 0000H LJMP MAIN ORG 000BH ; T0 ISR entry point LJMP T0ISR ORG 0030H ;above int vectors MAIN: . . T0ISR: . ; Timer 0 ISR RETI ;return to main

Timer The 8051 has two timers/counters, they can be used either as Timers to generate a time delay Event counters to count events happening outside the microcontroller Both Timer 0 and Timer 1 are 16 bits wide Since 8051 has an 8-bit architecture, each 16-bits timer is accessed as two separate registers of low byte (TLx) and high byte (THx)

Timer

Timer