EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.

Slides:



Advertisements
Similar presentations
Autumn 2012C.-S. Shieh, EC, KUAS, Taiwan1 The 8051 Family Microcontroller Chin-Shiuh Shieh Department of Electronic Engineering.
Advertisements

Week10 Boolean Instructions on the Boolean Instructions  Boolean (or Bit) addressable capability is unique to the 8051  Enables efficient handling.
Interrupts Professor Yasser Kadah –
1 Chapter 3 Jump, Loop, and Call Instructions. 2 Sections 3.1 Loop and Jump Instructions 3.2 Call Instructions 3.3 Time Delay Generation and Calculation.
8051 Core Specification.
Msc. Ivan A. Escobar Broitman Microprocessors 1 1 The 8051 Instruction Set.
CSC Timers Since this is a microcontroller it mainly finds itself in embedded devices Quite often embedded devices need to synchronize events The.
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.
Microcontroller Intel 8051
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
The 8051 Microcontroller architecture
ECE/CS-352: Embedded Microcontroller Systems Embedded Microcontroller Systems.
1 Chapter 4 Timer Operation (I. Scott MacKenzie).
Prof. Cherrice TraverEE/CS-152: Microprocessors and Microcontrollers The 8051 Assembly Language.
CIT 673 Created by Suriyong1 MCS51 ASSEMBLY Language Resources
CoE3DJ4 Digital Systems Design Chapter 4: Timer operation.
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.
The 8051 Assembly Language Branching & Subroutines
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.
ECE/CS-352: Embedded Microcontroller Systems The Silicon Laboratories C8051F020 Enhanced 8051 Part 4 Timer3, Temperature Sensor, AD0WINT.
Prof. Cherrice TraverEE/CS-152: Microprocessors and Microcontrollers The 8051 Assembly Language.
The 8051 Microcontroller and Embedded Systems
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.
The Silicon Laboratories C8051F020
Embedded Systems Design 1 Lecture Set 8 MCS-51 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.
Week 5 RISC &. CISC I/O Port Handling. CISC v.s. RISC CISC – Complex Instruction Set Computer RISC - Reduced Instruction Set Computer Historical perspective:
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.
Embedded Microcontroller Systems
80C51 Block Diagram ECE Overview.
Embedded Microcontroller Systems
Lecture Set 5 The 8051 Instruction Set.
Subroutines and the Stack
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
Interrupt Source: under
ECE,JYOTHI ENGG COLLEGE
Introduction to Micro Controllers & Embedded System Design Interrupt
UNIT 5 TIMRERS/COUNTERS
Data Processing Instructions
* * * * * * * 8051 Interrupts Programming.
SCHOOL OF ELECTRONICS ENGINEERING Electronics and Communication
Interrupt.
Lecture 8 Interrupts.
The 8051 Assembly Language Arithmetic & Logic Instructions
8051 Single Board Computer (SBC) Version 1.0
Timer.
Memory organization On- chip memory Off-chip memory
Branching Instructions
Introduction to Micro Controllers & Embedded System Design Instruction set Department of Electrical & Computer Engineering Missouri University of Science.
Subroutines and the Stack
Introduction to Micro Controllers & Embedded System Design Instruction set Department of Electrical & Computer Engineering Missouri University of Science.
Interrupt Source: under
Interrupt.
Interrupt Source: under
8051 Micro Controller.
Compiled by Dr. N.Shanmugasundaram, HOD, ECE Dept, SECE.
Subroutines and the Stack
8051 Development System Details
Presentation transcript:

EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts

Subroutines LCALL When a subroutine is called the PC is put on the stack: LCALL add16; long call to subroutine Encoding aaaaaaaa aaaaaaaa (3-byte instruction) Operation : (PC)  (PC) + 3 (SP)  (SP) + 1 ((SP))  (PC7-PC0) (SP)  (SP) + 1 ((SP))  (PC15 - PC8) (PC)  add15 - add0 This is all automatically done EE/CS-352: Embedded Microcontroller Systems

Subroutines RET The PC must be returned to its previous state to return correctly: RET - return from subroutine Encoding Operation - (PC15 - PC8)  ((SP)) (SP)  (SP) - 1 (PC7 - PC0)  ((SP)) (SP)  (SP) - 1 EE/CS-352: Embedded Microcontroller Systems

Pushbutton Remember that the clock is running at 2MHz and each instruction takes 1-4 cycles JB and JNB etc. will evaluate to true or false very quickly Normally, you will want to take into account the high and low time: forever: up: jb P3.7, up e.g. cpl LED down: jnb P3.7, down sjmp forever EE/CS-352: Embedded Microcontroller Systems

Interrupts … mov a, #2 mov b, #16 mul ab mov R0, a mov R1, b mov a, #12 mov b, #20 mul ab add a, R0 mov R0, a mov a, R1 addc a, b mov R1, a end Program Execution interrupt ISR:orl P1MDIN, #40h orl P1MDOUT,#40h setb P1.6 here:sjmp here cpl P1.6 reti return

EE/CS-352: Embedded Microcontroller Systems Interrupt Sources Original 8051 has 5 sources of interrupts – Timer 0 overflow – Timer 1 overflow – External Interrupt 0 – External Interrupt 1 – Serial Port events (buffer full, buffer empty, etc)

EE/CS-352: Embedded Microcontroller Systems Interrupt Process

EE/CS-352: Embedded Microcontroller Systems Interrupt Priorities What if two interrupt sources interrupt at the same time? The interrupt with the highest PRIORITY gets serviced first. All interrupts have a default priority order. (see page 117 of datasheet) Priority can also be set to “high” or “low”.

EE/CS-352: Embedded Microcontroller Systems Interrupt SFRs Global Interrupt Enable Interrupt enables for the 5 original 8051 interrupts: Serial (UART0) Timer 1 External 1 Timer 0 External 0 Set bits: 1 = Enable 0 = Disable

EE/CS-352: Embedded Microcontroller Systems Another Interrupt SFR Comparator 1 rising edge Comparator 1 falling edge Comparator 0 rising edge Comparator 0 falling edge Program Counter Array ADC0 Window Comparison System Management Bus SPI Interface

EE/CS-352: Embedded Microcontroller Systems Another Interrupt SFR Serial (UART) 1 External 7 External 6 ADC 1 Timer 4 ADC 0 Timer 3 External Clock source Valid

EE/CS-352: Embedded Microcontroller Systems External Interrupts /INT0 (Interrupt 0) and /INT1 (Interrupt 1) are external input pins.

EE/CS-352: Embedded Microcontroller Systems External Interrupts Interrupt 6 and Interrupt 7 use Port 3 pins 6 and 7: INT 6 = P3.6 INT 7 = P3.7 Interrupts 6 & 7 can be configured to be –rising edge-triggered –falling edge-triggered

EE/CS-352: Embedded Microcontroller Systems External Interrupts Interrupt flags: 0 = no falling edges detected since bit cleared 1 = falling edge detected Interrupt Edge Configuration: 0 = interrupt on falling edge 1 = interrupt on rising edge

EE/CS-352: Embedded Microcontroller Systems Example Configuration Configure Port 3, bit 7 (the pushbutton switch) to interrupt when it goes low. Configure Port: anl P3MDOUT, #0x7F ; Set P3.7 to be an input setb P3.7 mov XBR2, #40h ; Enable crossbar switch Configure Interrupt:

EE/CS-352: Embedded Microcontroller Systems Interrupt Vectors Each interrupt has a specific place in code memory (a vector) where program execution (interrupt service routine) begins (p17). Examples: External Interrupt 0: 0x0003 Timer 0 overflow: 0x000B External Interrupt 6: 0x0093 External Interrupt 7: 0x009B Note that there are only 8 memory locations between vectors.

EE/CS-352: Embedded Microcontroller Systems Interrupt Vectors To avoid overlapping Interrupt Service routines, it is common to put JUMP instructions at the vector address. This is similar to the reset vector. cseg at 009B; at EX7 vector ljmp EX7ISR cseg at 0x100; at Main program Main:... ; Main program... EX7ISR:... ; Interrupt service routine...; Can go after main program reti; and subroutines.

EE/CS-352: Embedded Microcontroller Systems Example Interrupt Service Routine ; EX7 ISR to blink the LED 5 times. ; Modifies R0, R5-R7, bank 3. ; ISRBLK: push PSW ; save state of status word mov PSW, #18h ; select register bank 3 mov R0, #10 ; initialize counter Loop2: mov R7, #02h ; delay a while Loop1: mov R6, #00h Loop0: mov R5, #00h djnz R5, $ djnz R6, Loop0 djnz R7, Loop1 cpl P1.6 ; complement LED value djnz R0, Loop2 ; go on then off 10 times pop PSW mov P3IF, #0; clear interrupt flag reti

EE/CS-352: Embedded Microcontroller Systems Practice Interrupting…