Chapter 6 Interrupts. (I. Scott Mackenzie) By: Masud-ul-Hasan

Similar documents
CoE3DJ4 Digital Systems Design. Chapter 6: Interrupts

8051 Interrupt Organization

Interrupts. EE4380 Fall 2001 Class 9. Pari vallal Kannan. Center for Integrated Circuits and Systems University of Texas at Dallas

CPEG300 Embedded System Design. Lecture 6 Interrupt System

8051 I/O and 8051 Interrupts

INTERRUPTS PROGRAMMING

MCS-51 Serial Port A T 8 9 C 5 2 1

Interrupt Programming: Interrupts vs. Polling Method:


e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Interrupt Handling Module No: CS/ES/13 Quadrant 1 e-text

CHAPTER 11 INTERRUPTS PROGRAMMING

Chapter 09. Programming in Assembly

The 8051 microcontroller has two 16-bit timers/counters called T0 and T1.

Mod-3: Interrupts,Timer operation,serial communication 1

8051 Timers. Class 7 EE4380 Fall Pari vallal Kannan. Center for Integrated Circuits and Systems University of Texas at Dallas

Department of EIE / Pondicherry Engineering College. Timer/Counters. Department of EIE / Pondicherry Engineering College 1

CoE3DJ4 Digital Systems Design. Chapter 5: Serial Port Operation

CPEG300 Embedded System Design. Lecture 8 Timer

Chapter 09. Programming in Assembly

Embedded Controller Programming

8051 Timers and Serial Port

8051 Microcontroller Interrupts

e-pg Pathshala Subject: Computer Science Paper: Embedded System Module: Interrupt Programming in Embedded C Module No: CS/ES/20 Quadrant 1 e-text

ELEG3923 Microprocessor Ch.9 Timer Programming

Vidyalankar T.E. Sem. V [ETRX] Microprocessors and Microcontrollers I Prelim Question Paper Solution

8051 Serial Port. EE4380 Fall02 Class 10. Pari vallal Kannan. Center for Integrated Circuits and Systems University of Texas at Dallas

The Timers/Counters The Serial Interface The Interrupt System Reset P0.0-P0.7 P2.0-P2.7. Port 2 Drivers. Port 2 Latch

8051 Microcontroller memory Organization and its Applications

Timers and interrupts

Serial I-O for Dinesh K. Sharma Electrical Engineering Department I.I.T. Bombay Mumbai (version 14/10/07)

INTEGRATED CIRCUITS DATA SHEET. P89C738; P89C739 8-bit microcontrollers Dec 15. Product specification File under Integrated Circuits, IC20

EE6502- MICROPROCESSOR AND MICROCONTROLLER

INSTITUTE OF AERONAUTICAL ENGINEERING Dundigal, Hyderabad ELECTRONICS AND COMMUNICATION ENGINEERING QUESTION BANK

Introduction To MCS-51

Microprocessors and Microcontrollers (EE-231)

MICROPROCESSORS AND MICROCONTROLLERS MATERIAL. Features of 8051:

Embedded Controller Programming II. I/O Device Programming in C Part 1: Input and Interrupts

3. (a) Explain the steps involved in the Interfacing of an I/O device (b) Explain various methods of interfacing of I/O devices.


Microcontroller and Embedded Systems:

CS 320. Computer Architecture Core Architecture

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Serial Port Programming in Assembly Module No: CS/ES/12 Quadrant 1 e-text

MASSEY UNIVERSITY PALMERSTON NORTH CAMPUS

8051 Serial Communication

8051 Core Specification

Chapter 3. Bit Addressable Area. By DeccanRobots

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI UNIT- IV

80C51 family programmer s guide and instruction set. 80C51 Family. PROGRAMMER S GUIDE AND INSTRUCTION SET Memory Organization. Philips Semiconductors

Rev. No. History Issue Date Remark

Microcontroller and Applications

8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT89S52

~: Simple Programs in 8051 assembly language :~

Lecture 9. Timer Operations and Programming

UNIT IV MICROCONTROLLER

ISSI. IS89C51 CMOS SINGLE CHIP 8-BIT MICROCONTROLLER with 4-Kbytes of FLASH ISSI IS89C51 NOVEMBER 1998 FEATURES GENERAL DESCRIPTION

Q 1 a) Attempt any THREE of the following: 12 TMOD.7 TMOD.6 TMOD.5 TMOD.4 TMOD.3 TMOD.2 TMOD.1 TMOD.0 GATE C/T M1 M0 GATE C/T M1 M0

Module I. Microcontroller can be classified on the basis of their bits processed like 8bit MC, 16bit MC.

8-bit Microcontroller with 2/4-Kbyte Flash AT89LP2052 AT89LP4052

The Final Word on 8051 Microcontroller

Programming Book Microcontroller Kit. Rev 3.0 January, Wichit Sirichote

VRS540-4kB Flash, 128B RAM, 25~40MHz, 8-Bit MCU

MODEL ANSWER WINTER 17 EXAMINATION Subject Title: Microcontroller and applications

ELEG3923 Microprocessor Ch.10 Serial Port Programming

MCS -51 Programmer s Guide and Instruction Set

How to use the PSoC based 16C450 Replacement

C51 Family. C51 Family Programmer s Guide and Instruction Set. Summary

Timer-1 can be run using the internal clock, fosc/12 (timer mode) or from any external source via pin T1 (P3.5) (Counter mode).

MLR INSTITUTE OF TECHNOLOGY DUNDIGAL , HYDERABAD

WINTER 14 EXAMINATION

8051 Microcontroller. Ali Ziya Alkar 1

Department of Electronics and Instrumentation Engineering Question Bank

T.Y. Diploma : Sem. V [EJ/EN/ET/EX/DE/IS/IC/IE/EV/MU] Micro-controller

VRS550-8kB Flash, 256B RAM, 25~40MHz, 8-Bit MCU VRS560-16kB Flash, 256B RAM, 40MHz, 8-Bit MCU

2. Write an 8051 program to generate a square wave of 25 khz at pin P2.3 using XTAL = 12 MHz. Solution:

8051 Microcontroller

8051 MICROCONTROLLER

Preliminary W77C32 8 BIT MICROCONTROLLER GENERAL DESCRIPTION FEATURES

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

80C51 Block Diagram. CSE Overview 1

A. This Errata sheet represents the known bugs, anomalies and work-arounds for the ADuC812 MicroConverter.

ELEG3923 Microprocessor Ch.4 I/O Ports

Advantages of Using a Dallas Semiconductor DS1232 MicroMonitor

AN108 IMPLEMENTING A REALTIME CLOCK. Relevant Devices. Introduction. Key Points. Overview

MICROCONTROLLER BASED WATER LEVEL CONTROL SYSTEM

Chapter C2051 Architecture and Serial Communication Link

7.2.1 Timer 2 Capture LSB... 24

C51 Family. Architectural Overview of the C51 Family. Summary

80C451 operation of port 6

Flash Microcontrollers. Application Note. Migrating from AT89C2051/C4051 to AT89LP2052/LP4052

UNIT THE 8051 INSTRUCTION SET AND PROGRAMMING

MODULE-1. Short Answer Questions

W77IE58 8-BIT MICROCONTROLLER. Table of Contents-- Publication Release Date: December Revision A2

8-BIT MICROCONTROLLER

Fig 1. Block diagram of a microcomputer

FACULTY OF ENGINEERING LAB SHEET

SUMMER 13 EXAMINATION

Timer Counter and Interrupt. Equation (16 bits counter, Mode 1, 16MHz):

Module 3. Embedded Systems I/O. Version 2 EE IIT, Kharagpur 1

Handshake Solutions. HT80C51 User Manual

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) Summer 2016 EXAMINATIONS.

Transcription:

Chapter 6 Interrupts (I. Scott Mackenzie) 1

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). 2

Program Execution 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 3

Program Execution 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 4

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. 5

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 6

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). 7

Interrupt Vector Addresses Interrupt 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. 8

Interrupt Vector Addresses 0030H Not reserved 002FH 5 002BH Timer 2 002AH 8 0023H Serial Port 0022H 8 001BH Timer 1 001AH 8 0013H External 1 0012H 8 000BH Entry Point Timer 0 000AH 8 0003H 0002H 0000H Entry Point External 0 System 3 Reset 9

IE : Interrupt Enable Register (0A8H) (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 EA ---- ---- ES ET1 EX1 ET0 EX0 10

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. 11

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. 12

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. 13

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 14

10KHz Square Wave on P1.0 Using Timer Interrupts ORG 0000H ;reset entry point LJMP Main ORG 000BH ;T0 interrupt vector T0ISR: CPL P1.0 ;toggle port bit RETI ORG 0030H Main: MOV TMOD,#02H ;T0 MODE 2 MOV TH0,#-50 ;50 ms DELAY SETB TR0 ;START TIMER 0 MOV IE,#82H ;ENABLE T0 INT SJMP $ ;DO NOTHING 15

Two 7KHz & 500Hz Square Waves Using Interrupts ORG 0 ;reset entry point LJMP Main ORG 000BH ;T0 interrupt vector LJMP T0ISR ORG 001BH ;T1 vector LJMP T1ISR ORG 0030H ;main starts here Main: MOV TMOD,#12H ;T0 mode 2, T1 mode 1 MOV TH0,#-71 ;7-kHz using T0 SETB TR0 ;START TIMER 0 SETB TF1 ;force T1 int MOV IE,#8AH ;ENABLE T0,T1 INT SJMP $ ;DO NOTHING 16

Two 7KHz & 500Hz Square Waves Using Interrupts (Continued) T0ISR: CPL P1.7 ;7-kHz on P1.7 RETI T1ISR: CLR TR1 ;stop T1 MOV TH1,#HIGH(-1000) MOV TL1,#LOW(-1000) ;1 ms for T1 SETB TR1 ;START TIMER 1 CPL P1.6 ;500-Hz on P1.6 RETI 17

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 18