Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB 1228

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

The 8051 Microcontroller and Embedded Systems
Interrupts Professor Yasser Kadah –
8051 Core Specification.
68HC11 Polling and Interrupts
CSC Timers Since this is a microcontroller it mainly finds itself in embedded devices Quite often embedded devices need to synchronize events The.
Interfacing. This Week In DIG II  Basic communications terminology  Communications protocols  Microprocessor interfacing: I/O addressing  Port and.
Communication Lab - Interrupts 1/13 Sequential Programming  Our C++ programs are sequential ( סדרתיים), they start at the first instruction and end at.
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.
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.
EEE527 Embedded Systems Lecture 8: Practical Interrupts Ian McCrumRoom 5B18, Tel: voice mail on 6 th ring Web site:
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.
The Functions of Operating Systems Interrupts. Learning Objectives Explain how interrupts are used to obtain processor time. Explain how processing of.
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.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
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.
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.
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.
Intel 8051 Another family of microcontroller is the Intel 8051 family. The basic 8051 microcontroller has four parallel input/output ports, port 0, 1,
ECE 447 Fall 2009 Lecture 7: MSP430 Polling and Interrupts.
7. IRQ and PIC ENGI 3655 Lab Sessions. Richard Khoury2 Textbook Readings  Interrupts ◦ Section
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Lecture 41 CSE 341 – Microprocessors Lecture 4 Md. Omar Faruqe UB 1228
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
بسم الله الرحمن الرحيم MEMORY AND I/O.
Embedded Computer - Definition When a microcomputer is part of a larger product, it is said to be an embedded computer. The embedded computer retrieves.
kashanu.ac.ir Microprocessors Interrupts Lec note 8.
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.
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.
Chapter 10 Interrupts. Basic Concepts in Interrupts  An interrupt is a communication process set up in a microprocessor or microcontroller in which:
Chapter 11 INTERRUPTS PROGRAMMING
80C51 Block Diagram ECE Overview.
8085 Interrupts LAKSHMI.B.E..
Microprocessor and Assembly Language
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
UNIT – Microcontroller.
Computer Architecture
Interrupts In 8085 and 8086.
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
* * * * * * * 8051 Interrupts Programming.
Interrupt.
Introduction to Micro Controllers & Embedded System Design Timer Operation Department of Electrical & Computer Engineering Missouri University of Science.
Timer.
Subject Name: Microprocessors Subject Code:10EC46 Department: Electronics and Communication Date: /20/2018.
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.
Timer Source: under
PIC18 Interrupt Programming
Presentation transcript:

Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB

Lecture 3 Notice Please your tasks to my university address. Submissions to other addresses won’t count. I use search to locate you assignments. So please make sure you use the following format: – CSE341 Task1 IdNo. – Please make sure Task1 is one word. 90% of you submitted assignment to different address. 1 followed the format above. 2 wrote Task 1 (with a space) 1 person didn’t mention Task1 in the subject. I should have explained this clearly. 2

Lecture 3 Execution of Instructions Execution of instructions of an Assembly program is sequential unless you use and instruction such as Jmp. 3 The PC (Program Counter) present in a microprocessor holds the memory location of the next instruction that is to be executed.

Lecture 34

5 Now in some cases we would like to perform operation when an external event takes place. There are two ways of monitoring this switch press Polling Interrupt

Lecture 3 Polling The processor checks to see if the external event has occurred at specific intervals. 6 Algorithm for polling: 1.Read P1.0 2.Is P1.0 equals to 0 ( The switch has been pressed?) a.Perform some external operation b c d Go to Step 1 What is the problem with this type of checking ?  Your Processors is BUSY/Tied up in the loop  You may actually miss the external even if not checked at the right time.

Lecture 3 Interrupts 7 The processor is automatically notified that an event has occurred. Think of the example of a phone: If your phone were on silent and you were expecting a call you would be checking at intervals to check for the call. On the other hand, if your phone has a ring tone than you could be doing anything and your phone would interrupt you and let you know that someone was calling you. The processor is automatically notified that an event has occurred.

Lecture 3 Interrupts Occur 8 The processor completes the current instruction its executing Saves the address of the next instruction on top of a Stack Jumps to a special location called the Interrupt Vector Table. The Interrupt Vector Table contains the address of the ISR (Interrupt Service Routine) There will be a specified ISR to handle each interrupt that they processor will come across. The ISR deals with the interrupt and takes the necessary actions as defined by the programmer. Once the ISR has been completed the processor returns to the execution of the original program. It does so by retrieving the instruction address which it saved on the top of the stack. Assembly programs use RETI to specify the return from Interrupt

Lecture 3 Interrupts & Priority 9 Suppose a microprocessor does three things.  Sends and receives data  Updates the display on a LED clock  Detects FIRE using a smoke alarm Suppose you were on the Phone and the Door Bell rings. What do you do ?  Ignore the Door and be on the phone  Hang up and answer the door. This is your personal preference. Microprocessors don’t have preferences, we need to set it for them. This is known as priority. What should it do if the three events occur at the same time ?

Lecture 3 Interrupts & Priority 10 Interrupts are a very important feature of microprocessors and modern O/S are built based on this ability of µP to use interrupts. On a µP there are generally two types of interrupts: External – Hardware based. Detected through electrical signals of special pins of the µP. Internal - o Timer-Based o Serial Communication (We will not be dealing with this). The 8051 has two pins that act can be used to detect external interrupts.

Lecture 3 Interrupt Structure of

Lecture 3 Port 3 12

Lecture 3 Interrupt Priority 13 By default all the external and internal interrupts are disabled. The programmer needs to enable interrupts within the program according to needs. The activation and set up of interrupts requires manipulation of some SFRs interrupt priority:  External Interrupt [INT0]  Timer 0  External Interrupt [INT1]  Timer 1  Serial Port

Lecture 3 Interrupt Vector Addresses 14 So you program is stored in memory locations 30H onwards.

Lecture 3 Program Memory 15 LocationsUser 00Boot strap / Microprocessor reads during start-up Reserved Interrupt Vector Addresses 30 OnwardsYour Program

Lecture 3 Setup for Interrupts 16 A SFR called IE (Interrupt Enable) is used to activate interrupts. IE is a 8 bit register and can be found at memory location A8 Each of the 8 bits are allocated to the various interrupts and the register is bit addressable. Being bit addressable each of the bits can be modified separately or directly.

Lecture 3 IE Structure 17 EA – Enable All acts as a switch. It either turns ON/OFF all the interrupts of the µP.

Lecture 3 Enable Interrupt INT0 18 SETB EX0 or SETB A8H Disable Interrupt INT0 CLRB EX0 or CLRB A8H

Lecture 3 Setting Up Interrupts 19 Other then IE there are SFRs that need to be set. Two more SFRs are needed to set up Interrupts:  TCON – Timer Control  IP – Interrupt Priority NOTE: To use interrupts correctly on 8051 three SFRs need to be initialised and set correctly.

Lecture 3 TCON 20 TF1: Timer 1 Overflow Flag TR1: Timer 1 Run Control Flag IE1: External Interrupt It is set to 1 by the processor when a high-to-low edge is received on the external interrupt pin INT1. It is cleared to zero when the processor vectors to ISR [ address:0013H]. IT1: External Interrupt 1 Signal Type Control Flag It may be set to 1 by the program to enable external interrupt 1 to be triggered by a floating edge signal. It is set to 0 by the program to enable Low-Level signal triggering on external interrupt INT1.

Lecture 3 IP 21 PS: Serial Port Priority: Set / Cleared by the program PT1: Priority of timer 1 overflow: Set / Cleared by the program PX1: Priority of external interrupt 1: Set / Cleared by the program PT0: Priority of timer 0 overflow: Set / Cleared by the program PX0: Priority of external interrupt 0: Set / Cleared by the program Priority may be 1 for the highest or 0 for lowest. In the 8051 only the highest and the lowest may be defined The other interrupts will use the default priority If the priorities are set incorrectly the processor will revert to default values.

Lecture 3 Exercise 22 Write an Assembly program for the 8051 to toggle the light when the switch is pressed.

Lecture 3 Hint 23

Lecture 3 Context Switching 24 The programmer must ensure that ISR leaves the registers in the same state as they were before. For 8051 the programmer must save contents of the following:  PSW  DPTR  Register A (Acc)  Register B  Registers How do you think this can be achieved ?

Lecture 3 Context Switching 25