Interrupt Source: http://www.edsim51.com/8051Notes/interfacing.html#adc under http://www.edsim51.com/8051Notes/index.html.

Slides:



Advertisements
Similar presentations
Interrupts Professor Yasser Kadah –
Advertisements

The 8051 Microcontroller Chapter 5 SERIAL PORT OPERATION.
Chapter 2 HARDWARE SUMMARY
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.
Chapter 6 Interrupts (I. Scott Mackenzie).
Architecture of the 8051 INTERNAL DATA BUS Oscillator & Timing Programmable I/O (32 Pins) 80C51 CPU 64K byte Expansion Control Serial I/O 4K Program Memory.
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.
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).
Lecture Set 9 MCS-51 Serial Port.
CoE3DJ4 Digital Systems Design Chapter 6: Interrupts.
Serial Communication Lec note 9.
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.
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.
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.
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.
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO microcontroller & programming.
Serial I/O Port.
Chapter 11 INTERRUPTS PROGRAMMING
Assembly Language * * * * * * * 8051 Timer
Microprocessor and Assembly Language
Source: Serial Port Source:
UNIT – Microcontroller.
8051 Timers Timers are the peripherals of the 8051 Microcontroller.
Interrupts In 8085 and 8086.
Timer Source: under
Hardware Source: ttp:// under
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
Interrupt Source: under
8085 Interrupts.
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.
An Introduction to Microprocessor Architecture using intel 8085 as a classic processor
Timer Operations and Programming
* * * * * * * 8051 Interrupts Programming.
Source: Serial Port Source:
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
Interrupts.
Interrupt.
Hardware Source: ttp:// under
JANAKIRAMAN E G S PILLAY ARTS AND SCIENCE COLLAGE NAGAPATTINAM DEPARTMENT OF PHYSICS.
Interrupt Source: under
INTRODUCTION TO 8051, A 8-BIT MICROCONTROLLER
Source: Serial Port Source:
Timer Source: under
Compiled by Dr. N.Shanmugasundaram, HOD, ECE Dept, SECE.
Interrupts of 8051 Introduction 8051 Interrupt organization
Source: Serial Port Source:
Presentation transcript:

Interrupt Source: http://www.edsim51.com/8051Notes/interfacing.html#adc under http://www.edsim51.com/8051Notes/index.html

What is an interrupt? An interrupt is the occurrence of an event that causes a temporary suspension of a program while the event is serviced by a section of code known as the interrupt service routine (ISR). Execution of main program code Execution of main program code Resumed execution of Execution of ISR Interrupt request Time

Processor’s response to an interrupt When an interrupt occurs, the following happens: The current instruction in the main program completes execution. The content of PC (i.e., the address of the next instruction in the main program) is saved on the stack. The address of ISR (i.e., Interrupt vector) for the interrupt is loaded into the PC. Subsequently, the ISR is executed. After the execution of the ISR is finished, PC is filled with the stack’s top word, which is the address of the next instruction in the main program. Subsequently, the execution of the main program is resumed. ISR: Interrupt Service Routine

What is a stack? A stack is a storage mechanism with the first-in-last-out (FILO) or last-in-first-out (LIFO) access scheme. Source: https://www.differencebtw.com/difference-between-queue-and-stack/

Five interrupt sources The 8051 has five interrupt sources: Two external interrupts: INT0-bar (port 3 pin 2); INT1-bar (port 3 pin 3) Two internal interrupts: Timer 0 overflow; Timer 1 overflow The serial port: when a byte has been transmitted or when a byte is received

Interrupt-related SFRs: IE, SCON, TCON

Interrupt-related SFR: IE (Interrupt Enable Register) An interrupt can be disabled and enabled. On power-up or reset, all interrupts are disabled. * To enable interrupts we set the appropriate bits in the interrupt enable SFR. Symbol Bit Number Description EA 7 Enable/disable all interrupts. If this bit is cleared all interrupts are disabled. If it is set each interrupt source is individually enabled or disabled by setting or clearing the appropriate enable bit, as detailed below. -- 6   5 ES 4 Enable/disable serial port interrupts (set to enable, clear to disable). ET1 3 Enable/disable timer 1 overflow interrupt (set to enable, clear to disable). EX1 2 Enable/disable external 1 interrupt (set to enable, clear to disable). ET0 1 Enable/disable timer 0 overflow interrupt (set to enable, clear to disable). EX0 Enable/disable external 0 interrupt (set to enable, clear to disable). Instructions for this purpose: SETB EA SETB ET0 CLR EX1

Interrupt-related SFR: TCON (Timer Control Register) Bit Symbol Bit Address Description 7 TF1 8FH Timer 1 overflow flag; set by hardware upon overflow, cleared by software. 6 TR1 8EH Timer 1 run-control bit; manipulated by software - setting starts timer 1, resetting stops timer 1. 5 TF0 8DH Timer 0 overflow flag; set by hardware upon overflow, cleared by software. 4 TR0 8CH Timer 0 run-control bit; manipulated by software - setting starts timer 0, resetting stops timer 0. 3 IE1 8BH ITx controls the triggering condition of external x interrupt, where x = 0 or 1. = 1: negative-edge triggering; = 0: low-level triggering. IEx is the interrupt flag for external x interrupt, where x = 0 or 1. = 1: An interrupt request is present; = 0: An interrupt request is absent. 2 IT1 8AH 1 IE0 89H IT0 88H

Interrupt-related SFR: SCON (Serial Control Register) Bit Symbol Address Description 7 SM0 9FH serial port mode bit 0 6 SM1 9EH serial port mode bit 1 5 SM2 9DH serial port mode bit 2 - will be dealt with at a later date 4 REN 9CH receiver enable - this bit must be set to receive data 3 TB8 9BH transmit bit 8 - this is the ninth bit transmitted in the 9-bit UART modes 2 RB8 9AH receive bit 8 - this is the ninth bit received in the 9-bit UART modes 1 TI 99H transmit interrupt flag - this bit is set by hardware when an entire byte has been transmitted - it must be cleared by software RI 98H receive interrupt flag - this bit is set by hardware when an entire byte has been received - it must be cleared by software

Interrupt Flags The 1st bit of TCON register Interrupt Flag Location External 0 IE0 TCON.1 External 1 IE1 TCON.3 Timer 0 TF0 TCON.5 Timer 1 TF1 TCON.7 Serial Port Receive RI SCON.0 Serial Port Transmit TI SCON.1 The 1st bit of TCON register

Interrupt Vectors Interrupt Source Interrupt Flag Interrupt Vector (Address in code memory) System reset RST 0000H External interrupt 0 IE0 0003H Timer 0 TF0 000BH External interrupt 1 IE1 0013H Timer 1 TF1 001BH Serial port RI or TI 0023H When an interrupt in the 8051 occurs, the vector address, as shown above, is loaded into the PC.

Scenario of Interrupting

External Interrupts Interrupt pins: the INT0-bar (P3.2) & INT1-bar (P3.3) pins Triggering conditions: a low-level or negative edge on the interrupt pins Choice of the triggering condition: the IT0 and IT1 bits (in the TCON register) The interrupt flags: IE0 and IE1 (in the TCON register); 0 for low-level triggering, 1 for negative edge triggering Sampling rate  The external interrupt pins are sampled (ie; tested) once every machine cycle. Note: Machine cycle = 1 us for 12 MHz clock rate

How to program an interrupt To do External Interrupt 0 Set up the interrupt vector ORG 3 JMP EXT0ISR Choose the interrupt triggering condition (negative-edge or low-level triggering) SETB IT0 ; for edge-triggering CLR IT0 ; for level-triggering Enable the interrupt SETB EX0 Enable all the interrupts SETB EA Program the ISR EXT0ISR:  RETI