Microprocessors 1 MCS-51 Interrupts.

Slides:



Advertisements
Similar presentations
Interrupts Professor Yasser Kadah –
Advertisements

Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
8051 Core Specification.
8085 Interrupts LAKSHMI.B.E.1. Interrupts  Interrupt is a process where an external device can get the attention of the microprocessor. ◦ The process.
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Chapter 6 Interrupts (I. Scott Mackenzie).
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
Midterm Wednesday 11/19 Overview: 25% First Midterm material - Number/character representation and conversion, number arithmetic - DeMorgan’s Law, Combinational.
The 8051 Microcontroller and Embedded Systems
INTERRUPTS PROGRAMMING
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:
Introduction to Embedded Systems
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
MICROPROCESSOR INPUT/OUTPUT
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.
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.
Interrupt Interrupt – to break the flow of speech or action of (someone) by saying or doing something (Longman dictionary)
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.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
1 © Unitec New Zealand Interrupt Lecture 6 Date: - 20 Sept, 2011 Embedded Hardware ETEC 6416.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
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.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
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.
Dec Hex Bin 14 E ORG ; FOURTEEN Interrupts In x86 PC.
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.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
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.
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.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Chapter 11 INTERRUPTS PROGRAMMING
8085 Interrupts LAKSHMI.B.E..
MICROPROCESSOR BASED SYSTEM DESIGN
Microprocessor and Assembly Language
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
The process starts from the I/O device
UNIT – Microcontroller.
Computer Architecture
Interrupts In 8085 and 8086.
Unit - 1 Interrupts M.Brindha AP/EIE
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
Interrupt.
* * * * * * * 8051 Interrupts Programming.
Interrupt.
Lecture 8 Interrupts.
Computer System Overview
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.
Interrupt Source: under
COMPUTER PERIPHERALS AND INTERFACES
Interrupts.
Interrupt.
Interrupts 1/18/2019.
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.
PIC18 Interrupt Programming
COMP3221: Microprocessors and Embedded Systems
Presentation transcript:

Microprocessors 1 MCS-51 Interrupts

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. Allow a system to respond asynchronously to an event and deal with the event while another program is executing. An interrupt driven system gives the illusion of doing many things simultaneously. Of course, the CPU cannot execute more than one instruction at a time. It can temporarily suspend execution of one program, execute another, then return to the first program. In a way, interrupts are like subroutines. Except that one does not know when the interrupt code will be executed.

Example An embedded system is controlling a Microwave oven. The main program is controlling the power element of the oven. The use presses a key on the front panel to cancel the operation or change the length of cooking time. The main program is interrupted. The ISR takes over, reads the keypad and changes the cooking conditions accordingly, then finishes by passing control back to the main program. The main program continues according to the new conditions set by the ISR. The important aspect is that the keypad entry occurs asynchronously with respect to the main program. The main program cannot anticipate when the key will be pressed.

Interrupts vs. Polling Polling: Interrupts CPU monitors all served devices continuously, looking for a “service request flag” Whenever it sees a request, it serves the device and then keeps polling CPU is always “busy” with polling doing the “while any request” loop Interrupts If and when a device is ready and needs attention, it informs the CPU CPU drops whatever it was doing and serves the device and then returns back to its original task CPU is always “free”, when not serving any interrupts

Interrupt Service Routines CPUs have fixed number of interrupts Every interrupt has to be associated with a piece of code called “Interrupt Service Routine”, or ISR. If interrupt-x is received by CPU, the ISR-x is executed CPU architecture defines a specific “code address” for each ISR, which is stored in the, “Interrupt vector Table (IVT)” ISRs are basically “subroutines”, but they end with the RETI, instruction instead of RET When an interrupt occurs, the CPU fetches its ISR code address from the IVT and executes it.

Interrupt Execution CPU finishes the instruction it is currently executing and stores the PC on the stack CPU saves the current status of all interrupts internally Fetches the ISR address for the interrupt from IVT and jumps to that address Executes the ISR until it reaches the RETI instruction Upon RETI, the CPU pops back the old PC from the stack and continues with whatever it was doing before the interrupt occurred

MCS-51 Interrupts There are 5 interrupts in the 8051. Clones may differ. Two external interrupts (INT0 and INT1), two timer interrupts (TF0 and TF1) and one serial port interrupt (SI). Interrupts can be individually enabled or disabled. This is done in the IE (Interrupt Enable) register (A8H). IE is bit addressable. All interrupts correspond to bits in registers. Therefore, it is possible to cause an interrupt by setting the appropriate bit in the appropriate register. The end result is exactly as if the hardware interrupt occurred.

The IE Register Putting a 1 in a bit enables its interrupt. MSB LSB EA - ET2 ES ET1 EX1 ET0 EX0 Bit Name Description IE.7 EA Enable/Disable all interrupts If 0 all interrupts are disabled. If 1, interrupts are enabled based on their individual bits IE.6 - Reserved IE.5 ET2 Enable/Disable Timer 2 interrupt (8052) IE.4 ES Enable/Disable Serial Input Interrupt IE.3 ET1 Enable/Disable Timer 1 Interrupt (TF1) IE.2 EX1 Enable/Disable External Interrupt 1 (INT1) IE.1 ET0 Enable/Disable Timer 0 Interrupt (TF0) IE.0 EX0 Enable/Disable External Interrupt 0 (INT0) Putting a 1 in a bit enables its interrupt. Putting a 0 masks that interrupt.

Interrupt Priority The 8051 implements 2 types of interrupt priority. User Defined Priority. Using the IP register, the user can group interrupts into two levels – high and low. An interrupt is assigned a “high” priority level by setting its bit in the IP register to 1. If the bit is set to 0, the interrupt gets a “low” priority. Automatic Priority. Within each priority level, a strict order is observed. Interrupts are ordered as follows: INT0, TF0, INT1, TF1, SO.

The IP Register MSB LSB - PT2 PS PT1 PX1 PT0 PX0 Bit Name Description IP.7 - Reserved IP.6 IP.5 ET2 Timer 2 interrupt priority (8052) IP.4 ES Serial Port Interrupt priority IP.3 ET1 Timer 1 Interrupt priority (TF1) IP.2 EX1 External Interrupt 1 priority (INT1) IP.1 ET0 Timer 0 Interrupt priority (TF0) IP.0 EX0 External Interrupt 0 priority (INT0) Putting a 1 in a bit assigns its interrupt to the high priority level.

Pending Interrupts If an interrupt occurs while it is disabled, or while a higher priority interrupt is active, it becomes pending. As soon as the interrupt is enabled, it will cause a call. It is also possible to cancel it by software by clearing the appropriate bit in the register.

Response Time Response time is the amount of time between the occurrence of the interrupt event and the start of execution of the service routine. For the MCS-51, the shortest possible response time is 3 machine cycles and the longest is 9. Interrupts are not recognized during specific instructions. An additional instruction must complete before interrupts will be recognized. RETI and any instruction that modifies the contents of IE or IP.

Activation Levels – INT0 and INT1 The activation for INT0 and INT1 can be configured to be level-triggered or edge-triggered based on bits IT0 and IT1 in the TCON register For level-triggered (ITx = 0, default), a low on the pin causes an interrupt. For edge-triggered (ITx = 1), a high-to-low transition causes the interrupt. MSB LSB TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0

INT0 and INT1 (Contd.) If INTx is configured as edge-triggered, then the change in value of the flag bit IEx in the TCON register is what causes the interrupt. It can be forced through software. If it is configured as level-triggered, then the interrupting device is what controls the value of the flag. The flag will be automatically cleared at the end of the ISR. After the RETI. Prevents interrupts of the same type within an interrupt.

Activation Levels – TF0 and TF1 The TF0 and TF1 interrupts are essentially edge-triggered. The interrupt occurs when the counter goes from FFFFH to 0000H. The flag goes from low to high. These flags will be automatically cleared when the ISR is started.

MCS-51 IVT Symbol Address Interrupt Source RESET 00H Power Up or Reset EXTI0 03H External Interrupt 0 TIMER0 0BH Timer 0 Interrupt EXTI1 13H External Interrupt 1 TIMER1 1BH Timer 1 Interrupt SINT 23H Serial Port Interrupt