Mark Redekopp, All rights reserved. EE 357 Unit 10b. Interrupts Timers

Similar documents
original M68K requests/priorities Interrupts to execute important code interrupts (n will always be I) I-bits bits in SR accomplish this

These three counters can be programmed for either binary or BCD count.

Grundlagen Microcontroller Interrupts. Günther Gridling Bettina Weiss

CHAPTER 11 INTERRUPTS PROGRAMMING

Module Introduction. PURPOSE: The intent of this module is to explain MCU processing of reset and interrupt exception events.

Interrupts in Zynq Systems

Types of Interrupts:

Mod5282 Programmable Interrupt Timer Application Note

8086 Interrupts and Interrupt Responses:

Mod5234 Interrupt Controllers Application Note

Microprocessors & Interfacing

Interrupts (I) Lecturer: Sri Notes by Annie Guo. Week8 1

INTERRUPTS in microprocessor systems

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

4) In response to the the 8259A sets the highest priority ISR, bit and reset the corresponding IRR bit. The 8259A also places

Lecture-51 INTEL 8259A Programmable Interrupt Controller

EEL 4744C: Microprocessor Applications. Lecture 7. Part 2. M68HC12 Interrupt. Dr. Tao Li 1

CPEG300 Embedded System Design. Lecture 6 Interrupt System

Design and Implementation Interrupt Mechanism

Course Introduction. Purpose: Objectives: Content: 27 pages 4 questions. Learning Time: 20 minutes

SECTION 7 SYSTEM INTEGRATION MODULE

2. List the five interrupt pins available in INTR, TRAP, RST 7.5, RST 6.5, RST 5.5.

sequence is not needed. (ROM space). Another application is to use the poll mode to expand the number of priority levels to more than 64.

Topics. Interfacing chips

PC Interrupt Structure and 8259 DMA Controllers

Week 11 Programmable Interrupt Controller

Chapter 9 Interrupt Controller

Timer 32. Last updated 8/7/18

12. Interrupts and Programmable Multilevel Interrupt Controller

Lab 4 Interrupt-driven operations

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

1 MALP ( ) Unit-1. (1) Draw and explain the internal architecture of 8085.

ARM Advanced Interrupt Controller

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 09, SPRING 2013

Lab 9: On-Board Time Generation and Interrupts

EEL 4744C: Microprocessor Applications. Lecture 7. Part 1. Interrupt. Dr. Tao Li 1

Reading Assignment. Interrupt. Interrupt. Interrupt. EEL 4744C: Microprocessor Applications. Lecture 7. Part 1

EE458 - Embedded Systems Exceptions and Interrupts

Lab 4: Interrupt. CS4101 Introduction to Embedded Systems. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan

Chapter 6 PROGRAMMING THE TIMERS

Interrupts Peter Rounce - room 6.18

UNIT - II PERIPHERAL INTERFACING WITH 8085

ECE251: Thursday September 27

Menu. Polling Example

Interrupt handling. Purpose. Interrupts. Computer Organization

Programming Embedded Systems

Wireless Sensor Networks (WSN)

Timers and Pulse Accumulator

Interrupts (Exceptions) Gary J. Minden September 11, 2014

Embedded Systems. October 2, 2017

LEGO RCX Hitachi H8/3292

Interrupt Basics Karl-Ragmar Riemschneider

MP Assignment III. 1. An 8255A installed in a system has system base address E0D0H.

CENG-336 Introduction to Embedded Systems Development. Timers

Fundamental concept in computation Interrupt execution of a program to handle an event

PPG Function of F2MC-16LX MCU Series as PWM

Marten van Dijk Department of Electrical & Computer Engineering University of Connecticut

Interrupts (Exceptions) (From LM3S1968) Gary J. Minden August 29, 2016

Interrupts Peter Rounce

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

Interrupts L33-1. Interrupts

Interrupt/Timer/DMA 1

SECTION 5 RESETS AND INTERRUPTS

Interrupt is a process where an external device can get the attention of the microprocessor. Interrupts can be classified into two types:

Detailed Nios II Exception Process

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

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

Interrupts. by Rahul Patel, Assistant Professor, EC Dept., Sankalchand Patel College of Engg.,Visnagar

Microprocessor Architecture

Northern India Engineering College, Delhi (GGSIP University) PAPER I


Pin diagram Common SignalS Architecture: Sub: 8086 HARDWARE

I/O - input/output. system components: CPU, memory, and bus -- now add I/O controllers and peripheral devices. CPU Cache

Timer Module Timer A. ReadMeFirst

SECTION 5 PROGRAM CONTROL UNIT

Introduction to Embedded Systems

Computer Architecture 5.1. Computer Architecture. 5.2 Vector Address: Interrupt sources (IS) such as I/O, Timer 5.3. Computer Architecture

Interrupts and Low Power Features

CPUs. Input and output. Supervisor mode, exceptions, traps. Co-processors. Computers as Components 4e 2016 Marilyn Wolf

Process Context & Interrupts. New process can mess up information in old process. (i.e. what if they both use the same register?)

COEN-4720 Embedded Systems Design Lecture 4 Interrupts (Part 1) Cristinel Ababei Dept. of Electrical and Computer Engineering Marquette University

For more notes of DAE

Microprocessors B (17.384) Spring Lecture Outline

Chapter Operation Pinout Operation 35

EE Embedded Systems Design. Lessons Exceptions - Resets and Interrupts

Lab 4 Interrupts ReadMeFirst

V8-uRISC 8-bit RISC Microprocessor AllianceCORE Facts Core Specifics VAutomation, Inc. Supported Devices/Resources Remaining I/O CLBs

Embedded Systems and Software

8085 Interrupts. Lecturer, CSE, AUST

AGH University of Science and Technology Cracow Department of Electronics

9. PERIPHERAL CHIPS 9a

Reset, Interrupts, Exceptions, and Break ECE 3534

An Interrupt is either a Hardware generated CALL (externally derived from a hardware signal)

Lecture 5: MSP430 Interrupt

INTERRUPTS PROGRAMMING

M68HC08 Microcontroller The MC68HC908GP32. General Description. MCU Block Diagram CPU08 1

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

AVR Timers TIMER0. Based on:

Lab 2: 80x86 Interrupts

Transcription:

EE 357 Unit 10b Interrupts Timers

IPL bits Coldfire / M68K Interrupts Coldfire interrupt architecture is based on original M68K 3-bit input (IPL[2:0]) indicating interrupt requests/priorities 000 = No interrupt 001-111 = Device 1-7 requesting interrupt Processor Core I/O Source Encoder 1 3 I/O Source 7 I/O Source

Masking Interrupts in the Processor Core May be times when we want the processor to execute important code and ignore (mask) interrupts I-bits bits in SR accomplish this Interrupt n will be ignored if n I-bits SR: 0 0 1 0 0 101 000 1 0 1 0 1 T S M I-bits X N Z V C I-bits=5: Ignore interrupts [1-5] SR: 0 0 1 0 0 000 000 1 0 1 0 1 T S M I-bits X N Z V C I-bits=0: Enable all interrupts

Non-Maskable Interrupt (NMI) I-bits = 7 would normally mean ignore all interrupts (n will always be I) Coldfire defines INT 7 as non-maskable Cannot be ignored even if I = 7 NMI is a safe guard to ensure some device can cause an interrupt no matter what.

Priority Inversion Problem Normally, higher priority interrupt should be handled before lower priority interrupts Example: INT 5 should be processed before INT 3 Priority inversion occurs when a lower priority interrupt occurs during handling of a higher priority interrupt

Priority Inversion Problem.text MAIN (INT 5).text ISR5 (INT 3).text ISR3 INT 3 interrupts ISR 5 and in effect INT 3 is handled before ISR 5 thus inverting the normal priority scheme. ORG $1000 Set I=5 MAIN (INT 5) Restore I Restore I ORG $1100 ISR5 (INT 3 ignored) Set I=3 ORG $1200 ISR3 Solution: Raise I-bits = n on interrupt n (Raise it to 5 on INT 5 so that INT 3 will be ignored until ISR 5 completes)

Interrupt Processing When an interrupt occurs, the CPU finishes the current instruction and then automatically goes through a 6 step process: 1. Ignore interrupt if n I-bits 2. Make a copy of the SR and Return Address/PC 3. Raise I-bits = n 4. Set S=1, T=0 5. Push Return Address and Copy of SR onto stack 6. Load PC with address from Exception Vector Table After handler finishes and calls RTE, original/copied SR will restore I-bit value

52259 Interrupt Priority Scheme 7 levels of priority for interrupts (higher priority interrupts are handled first) [Level 0 = No interrupt] MCF52259 has > 70 interrupt sources How to map over 70 sources to 7 levels? Break each level into 8 sub-priorities Allows a total ordering of interrupt sources Levels/Priorities are user-settable via control registers (i.e. timer0 can be set to level: 4, pri.: 1 or level: 6, pri.: 3) Highest Level 7 Priority 7 2-bits 3-bits 3-bits Lowest Level i Level 1 Priority 0 00 Interrupt Level Interrupt Priority ICRxx Register (Specifies the level and priority of interrupt source xx) Mark Redekopp, All rights reserved

Masking Interrupts MCF52259 provides several mechanisms to enable or disable (mask) interrupts Processor Core 3-bit value (Interrupt Priority Mask) in its SR (Status Register) allows only HIGHER priority interrupts (int n > I-bits of SR) Interrupt Controller Module IMR Register s Individual Interrupt Mask bits (1=Disable / 0=Enable) Clear this bit to enable that interrupt source IMR Register s Master Disable (Mask) bit Set this bit and ALL interrupts are disabled ICR Register Can set the level and priority for each interrupt source I/O Peripheral Block Interrupt Enable bit Must be set to 1 to allow that peripheral to attempt to generate interrupts

Interrupt Masking Control Bits Peripheral Block Interrupt Flag (IF) is the interrupt source IMRxx = Interrupt Mask Reg. (1=masks/ignores int., 0=allow int.) ICRxx = Interrupt Control Reg. Contains the desired 3-bit level (IPL value) Peripheral Block 000 ICRx 0 Mux 1 S IPL Processor Core > IntEn CPL I-bits IntFlag SR IMRx

Registering Interrupt Handlers Each interrupt source is assigned a number (so we know which mask bit and ICR to set) See 52259 Reference Manual Table 12-16 (Sec. 16.3.8.1) for source numbers Vector table is an array with one entry per interrupt source Each entry holds the starting address of a subroutine (handler) to be called when the interrupt occurs We will have to initialize the appropriate entry at startup 0x00000000 Vector Table (0x20000000) 0x20001ec0 addr2 0xfffffffc Addr. space 0x0 (unused) 0x20001ec0 addr2 INT 1 Hand. Code INT 2 Hand. Code INT 0 entry INT 1 entry INT 2 entry

Interrupt Configuration Process Initialization 1. Register handler routine in EVT 2. Enable local peripheral IE (int. en.) 3. Set the ICR to desired level 4. Clear the appropriate IMR mask bit 5. Set I-bits in SR (usually to 0) Operation Acknowledge interrupt (usually by writing a 1 to the interrupt flag bit) Mark Redekopp, All rights reserved

Acknowledging Interrupts As the first step in the interrupt handler you must clear the interrupt flag (source) to acknowledge that it is being handled and prevent it from generating more interrupt requests Sometimes accomplished by writing a 0 to a flag bit Sometimes accomplished by writing a 1 to a flag bit When timer interrupt occurs, the PIF bit is set to 1. We clear the PIF bit (set to 0 ) by writing a 1 to it 15-8 7 6 5 4 DOZE DBG OVW PIE PIF Programmable Interrupt Timer Control/Status Register (PCSR) 3 2 1 RLD 0 EN void pit0_handler() { MCF_PIT0_PCSR = MCF_PIT0_PCSR 0x0004;... }

EPORT (PORTNQ) EPORT (External) Interrupts Edge Port (EPORT) allows user-defined signals to generate an interrupt For our purposes, push buttons generating EPORT is really PORTNQ[7:1] Rather than using it as GPIO we can use it to sense interrupt conditions There are 7 pins (labeled from 7 to 1 rather than 6 to 0) MCF5211 1 2 3 4 5 6 7 Push Button Push Button

Edge Port Interrupts Can be set to generate an interrupt on A rising edge (transition from 0 to 1) A falling edge (transition from 1 to 0) Both rising and falling edges Level sensitive (generate an interrupt whenever signal is low 0 ) Falling Edge Rising Edge For edge settings Triggers only on an edge (1 interrupt no matter how long the signals is active) An edge will be recorded for handling later if the processor is busy with a higher priority INT For level sensitive Generates an interrupt whenever signal is active Will not be recorded (if processor is busy with higher interrupt, a level-sensitive interrupt will be lost) Mark Redekopp, All rights reserved Level Sensitive Interrupts

Edge Port Registers EPPAR Pin Assignment Sets edge or level-sensitivity EPIER Interrupt Enables Must be set to allow the interrupt sources to generate interrupts to the processor core EPDDR Data Direction Must set to input ( 0 ) to use as interrupt inputs EPFR Flag Register Indicates an interrupt has been generated. Must be cleared in the interrupt handler by writing a 1 to the appropriate bit 15 8 7 0 EPPAR (0=Level Sens. / 1=Falling-Edge / 2=Rising-Edge / 3=Both edges) 7 6 5 4 3 2 1 0 EPIER (1=Enable / 0=Disable) 7 6 5 4 3 2 1 0 EPDDR (1=output / 0=input) 7 6 5 4 3 2 1 0 EPFR (1=output / 0=input)

Programmable Interrupt Timer MCF52259 provides (2) programmable interrupt timers (PIT0 and PIT1) Operation Set a 16-bit counter with a value It will count down and when it reaches 0 it will generate an interrupt It can automatically reset to the start value and count down again for regular interrupts or simply stop and wait to be used again

Timer Control PMR (PIT Modulus Reg.) Counter initialization value PCNTR (PIT Counter) A Read to this returns the 16-bit counter value PCSR (PIT Control/Status Reg.) EN enables counter to count down Prescaler: (F Sysclk / 2) / 2 Prescale F Sysclk = 8 MHz in the MCF52259 OVW overwrite counter value when you write to PMR RLD Reload counter with PMR when it reaches 0 PIE Interrupt Enable PIF Flag generates IRQ; Write of 1, clears it. 15 PMR (High) 8 7 PMR (Low) 0 15 PMR (High) 8 7 PMR (Low) 0 DOZ E PMR (16-bit value) PCNTR (16-bit value) PRE DBG OVW PIE PIF RLD EN PCSR (16-bit value)

Timer Prescalar System clock runs at 8 MHz and we only have 16-bit down counter (i.e. max count of 65535) At 8 MHz, an interrupt would be generated in 65535 / (8E6 / 2) = 65535 / 4E6 = 16.384 ms Prescalar allows us to divide down the clock rate going into the counter New counter clock rate 4 MHz / 2 PRE To generate an interrupt for a specific interval, use the above formula selecting a prescalar [0-15], solve for PMR and ensure it is less than 65535. If it is greater than that, pick a larger prescalar and iterate. Interval = PMR * 2 PRE / 4*10 6

Timer Operation Internal Bus CLK PRE 16-bit Down Ctr. EN Read to PCNTR D LD 0 = PIE PIF IRQ EN PMR RLD OVW