Interrupt and Exception Programming

Slides:



Advertisements
Similar presentations
计算机系 信息处理实验室 Lecture 3 System Mechanisms (1)
Advertisements

DMA Controller (8237 Programming Examples)
Exceptions. Exception Types Exception Handling Vectoring Interrupts Interrupt Handlers Interrupt Priorities Interrupt applications 6-2.
Interrupts, Low Power Modes and Timer A (Chapters 6 & 8)
Cortex-M3 Exceptions and Interrupts
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
SCI: Serial Communications Interface Presented by: Sean Kline Chad Smith Jamie Cruce.
ECE 447 Fall 2009 Lecture 9: TI MSP430 Interrupts & Low Power Modes.
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Implementing interrupt driven IO. Why use interrupt driven IO? Positive points –Allows asynchronous operation of IO events –Good use of resources –Leads.
Hardware Support for Operating Systems Sunny Gleason Vivek Uppal COM S 414
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
Dr. Kimberly E. Newman Hybrid Embedded wk3 Fall 2009.
INTERRUPTS PROGRAMMING
Serial Communication Interface (SCI) Kevin Stuart Matt Betts March 27, 2007 ME 6405, Sp 07.
The Cortex-M3 Embedded Systems: The Cortex-M3 Processor Basics
The ARM Programmer’s Model
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.
V 0.91 Polled IO versus Interrupt Driven IO Polled Input/Output (IO) – processor continually checks IO device to see if it is ready for data transfer –Inefficient,
Lecture 23: LM3S9B96 Microcontroller - Interrupts.
CORTEX-M0 Structure Discussion 2 – Core Peripherals
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
Scott Baker Will Cross Belinda Frieri March 9 th, 2005 Serial Communication Overview ME4447/6405.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 part 4 Exceptions.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose  This training course provides an overview of the CPU architecture.
1 ARM University Program Copyright © ARM Ltd 2013 Using Direct Memory Access to Improve Performance.
Renesas Electronics America Inc. © 2011 Renesas Electronics America Inc. All rights reserved. RX Interrupt Control Unit (ICU) Ver
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학기 충북대학교 전자공학과 박 찬식
Exceptions and Interrupts Chap 7, 8 Tae-min Hwang.
Chapter 10 Interrupts. Basic Concepts in Interrupts  An interrupt is a communication process set up in a microprocessor or microcontroller in which:
-Low Power and System Control Features
ARM Cortex M3 & M4 Chapter 4 - Architecture
Interrupt and Exception Programming
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
ARM Cortex-M3 RTLAB 박 유 진.
Interrupts In 8085 and 8086.
Interrupts – (Chapter 12)
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
I/O - input/output system components: CPU, memory, and bus -- now add I/O controllers and peripheral devices CPU must perform all transfers to/from simple.
Chapter 8 Input/Output I/O basics Keyboard input Monitor output
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.
Interrupt and Exception Programming
YOVI 2008 Core Interrupt Controller (INTC)
* * * * * * * 8051 Interrupts Programming.
UART Serial Port Programming
Interrupt and Exception Programming
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.
Lecture 18 Interrupt 동국대학교 홍유표.
8259 Programmable Interrupt Controller
Lecture 9: TI MSP430 Interrupts & Low Power Modes
Interrupts.
Interrupts and Exception Handling
CNET 315 Microprocessor & Assembly Language
Interrupt and Exception Programming
Computer System Overview
CORTEX-M0 Structure Discussion 1
PIC18 Interrupt Programming
COMP3221: Microprocessors and Embedded Systems
Chapter 13: I/O Systems.
Interrupts and Exception Handling
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 (Hex)   Stack Pointer initial value 0x00000000 1 Reset 0x00000004 2 NMI 0x00000008 3 Hard Fault 0x0000000C 4 Memory Management Fault 0x00000010 5 Bus Fault 0x00000014 6 Usage Fault (undefined instructions, divide by zero, unaligned memory access,...) 0x00000018 7 Reserved 0x0000001C 8 0x00000020 9 0x00000024 10 0x00000028 11 SVCall 0x0000002C 12 Debug Monitor 0x00000030 13 0x00000034 14 PendSV 0x00000038 15 SysTick 0x0000003C 16 IRQ 0 for peripherals 0x00000040 17 IRQ 1 for peripherals 0x00000044 … 255 IRQ 239 for peripherals 0x000003FC

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 Memory Management Fault Programmable 5 Bus Fault 6 Usage Fault (undefined instructions, divide by zero, unaligned memory access,....) 7 Reserved 8 9 10 11 SVCall 12 Debug Monitor 13 14 PendSV 15 SysTick 16 IRQ 0 for peripherals 17 IRQ 1 for peripherals … 255 IRQ 239 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.

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.

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 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

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

ARM Cortex-M Registers

IRQ assignment in KL25Z of FRDM board INT# IRQ# Vector location Device 1-15 None 0000 0000 to 0000 003C CPU Exception (set by ARM) 16 0000 0040 DMA 17 1 0000 0044 18 2 0000 0048 19 3 0000 004C 20 4 0000 0050 ---- 21 5 0000 0054 FTFA 22 6 0000 0058 PMC 23 7 0000 005C LLWU 24 8 0000 0060 I2C0 25 9 0000 0064 I2C1 26 10 0000 0068 SPI0 27 11 0000 006C SPI1 28 12 0000 0070 UART0

IRQ assignment in KL25Z of FRDM board (Cont.) INT# IRQ# Vector location Device 29 13 0000 0074 UART1 30 14 0000 0078 UART2 31 15 0000 007C ADC0 32 16 0000 0080 CMP0 33 17 0000 0084 TPM0 34 18 0000 0088 TPM1 35 19 0000 008C TPM2 36 20 0000 0090 RTC 37 21 0000 0094 38 22 0000 0098 PIT 39 23 0000 009C ----- 40 24 0000 00A0 USB OTG 41 25 0000 00A4 DAC0 42 26 0000 00A8 TSI0 43 27 0000 00AC MCG 44 28 0000 00B0 LPTMR0 45 0000 00B4 46 0000 00B8 I/O PORTA 47 0000-00BC I/O PORTD

Interrupt enabling with all 3 levels

PORTx_PCRn register

Interrupts 0–31 Set Enable (EN0)

Interrupts 0–31 Clear Enable (DIS0)

Enabling and Disabling an Interrupt

PORTx_PCR Interrupt activation bits

I/O Interrupt Trigger D19 D18 D17 D16 1   1 Interrupt when logic zero (Active Low-level). Interrupt on rising edge. Interrupt on falling edge. Interrupt on either edge. Interrupt when logic one (Active High-level)

UARTx_Control2 (UARTx_C2)

UART Control 2 (UARTx_C2) register Field Bit Description TIE D7 Transmit Interrupt Enable bit. Used for interrupt-driven UART. 0 = TDRE Interrupt Request is disabled. 1 = TDRE Interrupt Request is enabled. TCIE D6 Transmission Complete Interrupt Enable bit. Used for interrupt-driven UART. 0 = TC Interrupt Request is disabled. 1 = TC Interrupt Request is enabled. RIE D5 Receiver Full Interrupt Enable bit. Used for interrupt-driven UART. 0 = RDRF Interrupt Request is disabled. 1 = RDRF Interrupt Request is enabled. ILIE D4 Idle Line Interrupt Enable bit. Used for interrupt-driven UART. 0 = IDLE Interrupt Request is disabled. 1 = IDLE Interrupt Request is enabled. TE D3 Transmitter Enable bit. We must enable this bit to transmit data. 0 = Transmitter is disabled. 1 = Transmitter is enabled. RE D2 Receiver Enable bit. We must enable this bit to receive data. 0 = Receiver is disabled. 1 = Receiver is enabled. RWU D1 Used for wake-up condition in stand-by mode. See the KL25Z manual. 0 = Normal operation 1 = RWU is enabled. SBK D0 Used for break bit. See the KL25Z manual. 0 = No break character 1 = Transmit break character

TOIE in TPMx_SC (Timer Status Control) register

SysTick Internal Structure

SysTick Control and Status Register (SYST_CSR)

SysTick Counting

IPRn Registers