Interrupt and Exception Programming

Slides:



Advertisements
Similar presentations
Interrupts, Low Power Modes and Timer A (Chapters 6 & 8)
Advertisements

Lizard Labs Peripheral Reflex System
I/O Unit.
ECE 447 Fall 2009 Lecture 9: TI MSP430 Interrupts & Low Power Modes.
Introduction of Holtek HT-46 series MCU
68HC11 Polling and Interrupts
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Introduction An interrupt is an event which informs the CPU that its service (action) is needed. Sources of interrupts: internal fault (e.g.. divide by.
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
Dr. Kimberly E. Newman Hybrid Embedded wk3 Fall 2009.
External & internal Interrupts. Interrupt Sources There are 21 different interrupts and each one has its own vector located in a predefined location at.
INTERRUPTS PROGRAMMING
The Cortex-M3 Embedded Systems: The Cortex-M3 Processor Basics
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
Lecture 23: LM3S9B96 Microcontroller - Interrupts.
CORTEX-M0 Structure Discussion 2 – Core Peripherals
AT91 Embedded Peripherals
Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose  This training course provides an overview of the CPU architecture.
IO Subsystem IV Ports and peripherals. IO Subsystem (1) All devices connected to the system buses, other than memory and CPU – Input and output ports.
AT91 Interrupt Handling. 2 Stops the execution of main software Redirects the program flow, based on an event, to execute a different software subroutine.
ECE 447 Fall 2009 Lecture 7: MSP430 Polling and Interrupts.
Renesas Electronics America Inc. © 2011 Renesas Electronics America Inc. All rights reserved. RX Interrupt Control Unit (ICU) Ver
kashanu.ac.ir Microprocessors Interrupts Lec note 8.
The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – Interrupts Refer to Chapter 4 in the reference book “Stellaris® LM3S9B96 Microcontroller - DATA.
Cortex-M3 Exceptions RTLAB. Hyeonggon Jo.  Exceptions Exception types & priority Abort model SVC and PendSV  Interrupt operation Pre-emption & Exit.
Interrupt 마이크로 프로세서 (Micro Processor) 2015년 2학기 충북대학교 전자공학과 박 찬식
Chapter 10 Interrupts. Basic Concepts in Interrupts  An interrupt is a communication process set up in a microprocessor or microcontroller in which:
1 The LPC1768 Architecture (with focus on Cortex-M3)
-Low Power and System Control Features
Embedded Microcontroller Systems
ARM Cortex M3 & M4 Chapter 4 - Architecture
Chapter 11 INTERRUPTS PROGRAMMING
Interrupt and Exception Programming
Interrupts and signals
ECE 3430 – Intro to Microcomputer Systems
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
Refer to Chapter 7, 8, 9 in the reference book
Mon. Oct 2 Announcements Quiz Postponed to Wednesday – still only on 2.a + 2.b Video lecture for 2.a posted Lab 6 experiment extension You must come to.
Timer and Interrupts.
Anton Burtsev February, 2017
Refer to Chapter 10 in the reference book
ARM Cortex-M3 RTLAB 박 유 진.
Interrupts In 8085 and 8086.
Interrupts – (Chapter 12)
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
Interrupt and Exception Programming
8259 Chip The Intel 8259 is a family of Programmable Interrupt Controllers (PIC) designed and developed for use with the Intel 8085 and Intel 8086 microprocessors.
YOVI 2008 Core Interrupt Controller (INTC)
* * * * * * * 8051 Interrupts Programming.
SPI Protocol and DAC Interfacing
Interrupt and Exception Programming
SPI Protocol and DAC Interfacing
Atmel ARM Timer Programming
Serial Communication Interface: Using 8251
Subject Name: Microprocessors Subject Code:10EC46 Department: Electronics and Communication Date: /20/2018.
Interrupt and Exception Programming
8259 Programmable Interrupt Controller
COMPUTER PERIPHERALS AND INTERFACES
Lecture 9: TI MSP430 Interrupts & Low Power Modes
CNET 315 Microprocessor & Assembly Language
Interrupt and Exception Programming
CORTEX-M0 Structure Discussion 1
PIC18 Interrupt Programming
Computer System Overview
COMP3221: Microprocessors and Embedded Systems
Presentation transcript:

Interrupt and Exception Programming Chapter 6 Interrupt and Exception Programming

Polling vs. Interrupts

NVIC in ARM Cortex-M

Interrupt Vector Table for ARM Cortex-M Memory Location   Stack Pointer initial value 0x00000000 1 Reset 0x00000004 2 NMI 0x00000008 3 Hard Fault 0x0000000C 4 Reserved 0x00000010 5 0x00000014 6 0x00000018 7 0x0000001C 8 0x00000020 9 0x00000024 10 0x00000028 11 SVCall 0x0000002C 12 0x00000030 13 0x00000034 14 PendSV 0x00000038 15 SysTick 0x0000003C 16 IRQ0 for peripherals 0x00000040 17 IRQ1 for peripherals 0x00000044 … 47 IRQ31 for peripherals 0x000000BC

Going from Reset to Boot Program

ARM Cortex-M Stack Frame upon Interrupt

Main Program gets interrupted

Interrupt Priority for ARM Cortex-M Priority Level Stack Pointer initial value   1 Reset -3 Highest 2 NMI -2 3 Hard Fault -1 4 Reserved 5 6 7 8 9 10 11 SVCall Programmable 12 13 14 PendSV 15 SysTick 16 IRQ 0 for peripherals 17 IRQ 1 for peripherals … 47 IRQ 31 for peripherals

CONTROL Register in ARM Cortex-M4   nPRIV (Privilege): Defines the Thread mode privilege level 0: Privileged 1: Unprivileged Active Stack Pointer (ASP): Defines the currently active stack pointer (ASP = SPSEL) 0: MSP is the current stack pointer. 1: PSP is the current stack pointer. Floating Point Context Active (FPCA) 0: No floating point context active. 1: Floating point context active.

Privileged level Execution and Processor Modes in ARM Cortex-M Software Privilege level Thread Applications Privileged and Unprivileged Handler ISR for Exceptions and IRQs Always Privileged Note: In Thread mode, use bit 0 of the CONTROL register to select Privileged or Unprivileged

Processor Modes and Stack Usage in ARM Cortex-M Software Stack Usage Thread Applications MSP or PSP Handler ISR for Exceptions and IRQs MSP Note: In Thread mode, use bit 1 of the Control register to select MSP or PSP for stack pointer.

Processor Mode, Privilege, and Stack in ARM Cortex Stack Pointer Typical Example usage Handler Privileged Main Exception Handling Unprivileged Any Reserved since Handler is always Privileged Thread Operating system kernel Process   Application threads

ARM Cortex-M Registers

Special function registers of ARM Cortex-M Register name Privilege Usage MSP (main stack pointer) Privileged PSP (processor stack pointer) Privileged or Unprivileged PSR (Processor status register) APSR (application processor status register) ISPR (interrupt processor status register) EPSR (execution processor status register) PRIMASK (Priority Mask register) FAULTMASK(fault mask register) BASEPRI (base priority register) CONTROL (control register) Note: We must use MSR and MRS instructions to access the above registers

IRQ assignment in SAMD21J INT# IRQ# Vector location Device 1-15   0000 0000 to 0000 003C CPU Exception 16 0000 0040 Power management 17 1 0000 0044 System Control 18 2 0000 0048 WDT - Watchdog Timer 19 3 0000 004C RTC – Real Time Counter 20 4 0000 0050 EIC – External Interrupt Controller 21 5 0000 0054 NVMCTRL – Non-Volatile Memory Controller 22 6 0000 0058 DMAC - Direct Memory Access Controller 23 7 0000 005C USB - Universal Serial Bus 24 8 0000 0060 EVSYS – Event System 25 9 0000 0064 Serial Communication Interface 0 26 10 0000 0068 Serial Communication Interface 1 27 11 0000 006C Serial Communication Interface 2 28 12 0000 0070 Serial Communication Interface 3

IRQ assignment in SAMD21J (Cont.) INT# IRQ# Vector location Device 29 13 0000 0074 Serial Communication Interface 4 30 14 0000 0078 Serial Communication Interface 5 31 15 0000 007C TCC0 – Timer Counter for Control 0 32 16 0000 0080 TCC1 – Timer Counter for Control 1 33 17 0000 0084 TCC2 – Timer Counter for Control 2 34 18 0000 0088 TC3 – Timer Counter 3 35 19 0000 008C TC4 – Timer Counter 4 36 20 0000 0090 TC5 – Timer Counter 5 37 21 0000 0094 TC6 – Timer Counter 6 38 22 0000 0098 TC7 – Timer Counter 7 39 23 0000 009C ADC – Analog-to-Digital Converter 40 24 0000 00A0 AC – Analog Comparator 41 25 0000 00A4 DAC – Digital-to-Analog Converter 42 26 0000 00A8 PTC – Peripheral Touch Controller 43 27 0000 00AC I2S - Inter IC Sound

EIC Block Diagram

Associations of I/O pins to EXTINT signals EIC PA00 EXTINT[0] PA16 PB00 PB16 PA01 EXTINT[1] PA17 PB01 PB17 PA02 EXTINT[2] PA18 PB02   PA03 EXTINT[3] PA19 PB03 PA04 EXTINT[4] PA20 PB04 PA05 EXTINT[5] PA21 PB05 PA06 EXTINT[6] PA22 PB06 PB22 PA07 EXTINT[7] PA23 PB07 PB23 PA08 NMI PA28 EXTINT[8] PB08 PA09 EXTINT[9] PB09 PA10 EXTINT[10] PA30 PB10 PA11 EXTINT[11] PA31 PB11 PA12 EXTINT[12] PA24 PB12 PA13 EXTINT[13] PA25 PB13 PA14 EXTINT[14] PB14 PB30 PA15 EXTINT[15] PA27 PB15 PB31

The CONFIGn registers with FILTENx and SENSEx bits packed into two registers

Input sense configuration SENSEx[2:0] Detection None 1 Rising-edge 2 Falling-edge 3 Both-edges 4 High-level 5 Low-level 6-7 reserved

INTENSET register

Set Enable Register (ISER[0]) for IRQ 0–31

Clear Enable Register (ICER[0]) for IRQ 0–31

Enabling and Disabling an Interrupt

Interrupt Enable Set ( INTENSET) register

Interrupt flag (INTFLAG) register

SERCOMx Interrupt Enable Set (INTENSET) Register in USART mode Field Bit Description ERROR 7 Error Interrupt Enable 0: Error interrupt is disabled. 1: Error interrupt is enabled. RXC 2 Receive Complete Interrupt Enable 0: Receive Complete interrupt is disabled. 1: Receive Complete interrupt is enabled. TXC 1 Transmit Complete Interrupt Enable 0: Transmit Complete interrupt is disabled. 1: Transmit Complete interrupt is enabled. DRE Data Register Empty Interrupt Enable 0: Data Register Empty interrupt is disabled. 1: Data Register Empty interrupt is enabled.

SysTick Internal Structure

SysTick Control and Status Register (SYST_CSR)

Interrupt Enable Set (INTENSET) Register

INTENSET Register Bits Name Description 5-4 MCx Match or Capture Channel x Interrupt Enable 0: The Match or Capture Channel x interrupt is disabled. 1: The Match or Capture Channel x interrupt is enabled. OVF Overflow Interrupt Enable 0: The Overflow interrupt is disabled. 1: The Overflow interrupt is enabled.

IPRn Registers