Chapter 6 Interrupts (I. Scott Mackenzie).

Slides:



Advertisements
Similar presentations
Interrupts Professor Yasser Kadah –
Advertisements

The 8051 Microcontroller Chapter 5 SERIAL PORT OPERATION.
8051 Core Specification.
CSC Timers Since this is a microcontroller it mainly finds itself in embedded devices Quite often embedded devices need to synchronize events The.
8051 Interrupts.  Contrast edge-triggered with level-triggered interrupts  Program the 8051 for interrupt-based serial communication  Define the interrupt.
Embedded Systems UNIT 3. Pin Details of 8051 Pins 1-8: Port 1 Each of these pins can be configured as an input or an output. Pin 9: The positive voltage.
1.  8051 Timers “count up,” incrementing the Timer’s respective “count register” each time there is a triggering clock pulse. 2  When the “count register”
The 8051 Microcontroller and Embedded Systems
INTERRUPTS PROGRAMMING
Lecture 9 Timer Operations and Programming. 2  Introduction  Summary of timers  Timer programming sequence  Summary of timer SFRs  Timer 0: 8-bit.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
1 Chapter 4 Timer Operation (I. Scott MacKenzie).
Chapter 4 TIMER OPERATION
CoE3DJ4 Digital Systems Design Chapter 4: Timer operation.
Lecture Set 9 MCS-51 Serial Port.
CoE3DJ4 Digital Systems Design Chapter 6: Interrupts.
PIC16F877 ISR Points to note Interrupt Triggers –Individual interrupt flag bits are set, regardless of the status of their corresponding mask bit, PEIE.
Interrupt.
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.
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.
Intel 8051 Another family of microcontroller is the Intel 8051 family. The basic 8051 microcontroller has four parallel input/output ports, port 0, 1,
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.
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB 1228
kashanu.ac.ir Microprocessors Interrupts Lec note 8.
Interrupt-Driven I/O There are different types of interrupts –Hardware Generated by the 8259 PIC – signals the CPU to suspend execution of the current.
CS-280 Dr. Mark L. Hornick 1 Sequential Execution Normally, CPU sequentially executes instructions in a program Subroutine calls are synchronous to the.
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.
Timer Programming in Assembly and C Prepared By:
80C51 Block Diagram 1. 80C51 Memory Memory The data width is 8 bits Registers are 8 bits Addresses are 8 bits – i.e. addresses for only 256.
Lecture – 8 Interrupt 1. Outline Introduction Handling interrupt Interrupt sources Switching interrupt Peripheral interrupts Using two interrupts Conclusions.
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO microcontroller & programming.
Chapter 11 INTERRUPTS PROGRAMMING
80C51 Block Diagram ECE Overview.
Interrupts and interrupt responses
8085 Interrupts LAKSHMI.B.E..
Microprocessor and Assembly Language
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
Computer Architecture
8051 Timers Timers are the peripherals of the 8051 Microcontroller.
Interrupts In 8085 and 8086.
Timer Source: under
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
Introduction to Micro Controllers & Embedded System Design I/O Processing and Serial Port Operation Department of Electrical & Computer Engineering Missouri.
Timer Operations and Programming
* * * * * * * 8051 Interrupts Programming.
Interrupt.
Lecture 8 Interrupts.
Introduction to Micro Controllers & Embedded System Design Timer Operation Department of Electrical & Computer Engineering Missouri University of Science.
Timer.
8051 Timers / Counters It has two timers Timer 0 and Timer 1.
Timer Source: under
Interrupt Source: under
Interrupt.
JANAKIRAMAN E G S PILLAY ARTS AND SCIENCE COLLAGE NAGAPATTINAM DEPARTMENT OF PHYSICS.
Interrupt Source: under
Timer Source: under
Compiled by Dr. N.Shanmugasundaram, HOD, ECE Dept, SECE.
PIC18 Interrupt Programming
Interrupts of 8051 Introduction 8051 Interrupt organization
Presentation transcript:

Chapter 6 Interrupts (I. Scott Mackenzie)

Interrupts An interrupt is the occurrence of an event that causes a temporary suspension of a program while the condition is serviced by another program. It is like a sub-routine. CPU cannot execute more than one instruction at a time; but it can temporarily suspend execution of one program, execute another, then return to the first program. Difference in interrupt and subroutine is that in an interrupt-driven system, the interruption occur asynchronously with the main program, and it is not known when the main program will be interrupted. Program that deals with the interrupt is called as ISR (Interrupt Service Routine).

Program Execution Program execution without interrupts Main Program Time Program execution without interrupts ISR ISR ISR ISR Main Main Main Main Main Time Interrupt Return from interrupt instruction Program execution with interrupts

Program Execution Program execution without interrupts Main Program Time Program execution without interrupts ISR ISR ISR ISR Main Main Main Main Main Interrupt Return from interrupt instruction Program execution with interrupts

Interrupt System - Five interrupt sources in order of polling (priority) sequence are: External Interrupt 0 Timer 0 External Interrupt 1 Timer 1 Serial Port The polling sequence is fixed but each interrupt type can be programmed to one of two priority levels. If two interrupts of same priority occur simultaneously then polling sequence will determine which is serviced first. - External interrupts can be programmed for edge or level sensitivity. - Each interrupt type has a separate vector address. - All interrupts are disabled after a system reset and enabled individually by software.

Processing Interrupts When an interrupt occurs and is accepted by CPU, the following actions occur: Current instruction’s complete execution PC is saved on the stack PC is loaded with the vector address of the ISR ISR executes and takes action in response to interrupt ISR finishes with a RETI instruction PC is loaded with its old value from the stack Execution of main program continues where it left off

Interrupt Vector When an interrupt is accepted, the value loaded into the PC is called the interrupt vector. It is the address of the start of the ISR for the interrupting source. When an interrupt is vectored, the flag that caused the interrupt is automatically cleared by hardware. Timer interrupts occur when the timer registers (TLx/THx) overflow and set the overflow flag (TFx).

Interrupt Vector Addresses Flag Vector Address SFR & Bit Position System Reset RST 0000H External 0 IE0 0003H TCON.1 Timer 0 TF0 000BH TCON.5 External 1 IE1 0013H TCON.3 Timer 1 TF1 001BH TCON.7 Serial Port RI or TI 0023H SCON.0 or SCON.1 Each one is 8 byte in size.

IE : Interrupt Enable Register (0A8H) EA ---- ---- ES ET1 EX1 ET0 EX0 (1 = Enabled, 0 = Disabled) - EA : Global interrupt enable/ disable. - EX0: External interrupt 0 enable/ disable. - ET0: Timer 0 interrupt enable/ disable. - EX1 : External interrupt 1 enable/ disable. - ET1 : Timer 1 interrupt enable/ disable. - ES : Serial port interrupt enable/ disable. e.g., Timer 1 interrupt can be enabled as follows: SETB EA ; Enable global interrupt bit SETB ET1 ; Enable Timer 1 interrupt Or MOV IE, #10001000B

IP: Interrupt Priority Register (0B8H) ----- ----- ----- PS PT1 PX1 PT0 PX0 (1 = High priority, 0 = Low priority) PX0 : Priority for External interrupt 0. PT0 : Priority for Timer 0 interrupt. PX1 : Priority for External interrupt 1. PT1: Priority for Timer 1 interrupt. PS : Priority for Serial port interrupt. IP is cleared after a system reset to place all interrupts at the lower priority level by default.

SCON : Serial Port CONtrol Register (098H) SMO SM1 SM2 REN TB8 RB8 TI RI Serial Interrupts TI: Transmit interrupt flag. Set at the end of character transmission; cleared by software. RI: Receive interrupt flag. Set at the end of character reception; cleared by software.

External Interrupts External interrupt occurs as a result of a low-level or negative-edge on the INT0 or INT1 pin of 8051. Flags that generate these interrupts are bits IE0 and IE1 in TCON. These are automatically cleared when the CPU vectors to the interrupt. Low-level or negative-edge activated interrupts can be programmed through IT0 and IT1 bits in TCON, i.e., ITx = 0 means low-level and ITx = 1 means negative-edge triggered.

TCON : Counter/Timer CONtrol Register (088H) TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0 Timers Interrupts - TF1, TF0 : Overflow flags for Timer 1 and Timer 0. * - TR1, TR0 : Run control bits for Timer 1 and Timer 0. * Set to run, reset to hold. - IT1, IT0 : Type bit for external interrupts. Set for falling edge interrupts, reset for low level interrupts. - IE1, IE0 : Flag for external interrupts 1 and 0. Set by interrupt, cleared when interrupt is processed. * = related to counter/timer operation

Furnace Controller HOT=0 if T>21 INT0 (P3.2) COLD =0 if T< 19 INT1 (P3.3) ORG 0000H LJMP MAIN ; 3-bytes long EX0ISR: CLR P1.7 ; EX0 vector at 0003H RETI ; turn furnace OFF ORG 0013H EX1ISR: SETB P1.7 ; turn furnace ON RETI ORG 0030H MAIN: MOV IE, #85H ; enable external interrupts SETB IT0 ; negative edge triggered   SETB IT1 SETB P1.7 ; turn furnace ON initially   JB P3.2, SKIP ; if T>21°, P3.2 is zero   CLR P1.7 ; turn furnace OFF SKIP: SJMP $ ; do nothing   END