Www.ee.ntou.edu.tw Department of Electrical Engineering, National Taiwan Ocean University ARM Cortex-M0 Introduction 3/1/2012 Richard Kuo Assistant Professor.

Slides:



Advertisements
Similar presentations
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Advertisements

Exceptions. Exception Types Exception Handling Vectoring Interrupts Interrupt Handlers Interrupt Priorities Interrupt applications 6-2.
Cortex-M3 Memory Systems
8051 Core Specification.
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
Exception Processing ECE511: Digital System & Microprocessor.
Chapter 12 Three System Examples The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.
1 Computer System Overview OS-1 Course AA
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Interrupt Mechanisms in the 74xx PowerPC Architecture Porting Plan 9 to the PowerPC Architecture Ajay Surie Adam Wolbach.
COMPUTER SYSTEMS An Integrated Approach to Architecture and Operating Systems Chapter 4 Processor Implementation ©Copyright 2008 Umakishore Ramachandran.
ARM Core Architecture. Common ARM Cortex Core In the case of ARM-based microcontrollers a company named ARM Holdings designs the core and licenses it.
The Cortex-M3 Embedded Systems: The Cortex-M3 Processor Basics
Cortex-M3 Debugging System
Exception and Interrupt Handling
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.
Protection and the Kernel: Mode, Space, and Context.
Lecture 23: LM3S9B96 Microcontroller - Interrupts.
CORTEX-M0 Structure Discussion 2 – Core Peripherals
Universal Asynchronous RX/TX
Department of Electrical Engineering, National Taiwan Ocean University NuMicro MCU Learning Board SDK Installation 3/7/2013 Richard.
Department of Electrical Engineering, National Taiwan Ocean University Pulse Width Modulation 4/25/2013 Richard Kuo Assistant Professor.
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
Department of Electrical Engineering, National Taiwan Ocean University LCD Display 3/28/2013 Richard Kuo Assistant Professor.
ECE 353 Introduction to Microprocessor Systems Discussion 11.
Cortex-M0 MCU Interface and Driver Design - Course Overview
Department of Electrical Engineering, National Taiwan Ocean University Basic Electronics 3/7/2013 Richard Kuo Assistant Professor.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose  This course provides an overview of the CPU architecture.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose  This training course provides an overview of the CPU architecture.
Department of Electrical Engineering, National Taiwan Ocean University Timer/WatchDog /RTC 4/11/2013 Richard Kuo Assistant Professor.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
ARM Cortex-M0 August 23, 2012 Paul Nickelsberg Orchid Technologies Engineering and Consulting, Inc. CORTEX-M0 Structure Discussion.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
Virtual 8086 Mode  The supports execution of one or more 8086, 8088, 80186, or programs in an protected-mode environment.  An 8086.
Serial Peripheral Interface
AT91 Interrupt Handling. 2 Stops the execution of main software Redirects the program flow, based on an event, to execute a different software subroutine.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction  Purpose:  This course provides an overview of the Direct Memory.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
General Purpose Input/Output
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
بسم الله الرحمن الرحيم MEMORY AND I/O.
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.
ARM7 TDMI INTRODUCTION.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Department of Electrical Engineering, National Taiwan Ocean University I2C Bus 5/16/2013 Richard Kuo Assistant Professor.
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.
1 The LPC1768 Architecture (with focus on Cortex-M3)
-Low Power and System Control Features
Interrupts and signals
Microprocessor Systems Design I
Refer to Chapter 7, 8, 9 in the reference book
Timer and Interrupts.
ARM Cortex-M3 RTLAB 박 유 진.
Computer System Overview
BIC 10503: COMPUTER ARCHITECTURE
Architectural Support for OS
CORTEX-M0 Structure Discussion 1
Architectural Support for OS
Presentation transcript:

Department of Electrical Engineering, National Taiwan Ocean University ARM Cortex-M0 Introduction 3/1/2012 Richard Kuo Assistant Professor

Department of Electrical Engineering, National Taiwan Ocean University Outline ► ARM Processors roadmap ► ARM Cortex-M0 roadmap ► Cortex-M0 performance ► Cortex-M0 functional blocks ► Cortex-M0 architecture overview ► Memory Model ► Exception Model ► Cortex-M0 address map ► System Control Space ► System Timer ► NVIC

Department of Electrical Engineering, National Taiwan Ocean University ARM Processors roadmap Reference from ARM

Department of Electrical Engineering, National Taiwan Ocean University ARM Cortex-M Series roadmap Reference from ARM

Department of Electrical Engineering, National Taiwan Ocean University Cortex-M0 performance Reference from ARM

Department of Electrical Engineering, National Taiwan Ocean University Cortex-M0 Functional Blocks ► Cortex-M0 processor includes –Cortex-M0 processor core –Nested Vectored Interrupt Controller (NVIC) –System Timer (SysTick) Cortex-M0 Processor core Cortex-M0 Processor core Nested Vectored Interrupt Controller (NVIC) Nested Vectored Interrupt Controller (NVIC) System Timer (SysTick) System Timer (SysTick) ROM RAM Peripherals ROM RAM Peripherals Interrupts AHB-Lite interface Cortex-M0

Department of Electrical Engineering, National Taiwan Ocean University Cortex-M0 Architecture Overview ► ARMv6-M (which is a subset of ARMv7-M, upward compatible) –It supports only the Thumb instruction set. No Interworking code is required. –Total are 56 instructions. 6 are 32-bit length, the others are 16-bit length 32-bit instructions : BL, DMB, DSB, ISB, MRS, MSR ► Supports byte (8-bit), halfword (16-bit) and word (32-bit) data types, each must be accessed with natural alignment. ► Processor modes are Thread and Handler. –Always in privilege –Supports hardware key context state saving and restoring (Need not Assembly coding for ISR). ► Built-in timer and interrupt controller –NVIC, Systick ► Memory mapped I/O –Use same instructions to access memory and registers –Ex : LDR, STR

Department of Electrical Engineering, National Taiwan Ocean University Memory Model ► 32-bit address space ► Virtual memory is not supported in ARMv6-M. ► Instruction fetches are always halfword-aligned ► Data accesses are always naturally aligned –Ex : word at address A : A, A+1, A+2 and A+3.

Department of Electrical Engineering, National Taiwan Ocean University Exceptional Model ► An exception may be an interrupt or a hardware error ► Each exception has exception number, priority number and vector address –Vector address –Vector table base address is fixed at 0x x Vector address of exception 1 Vector address of exception 2 Initial value of stack Vector address of exception 47 Vector Table Word 0 Word 1 Word 2 Word 47

Department of Electrical Engineering, National Taiwan Ocean University Exception Model – cont. Exception number ExceptionPriority level 1Reset-3 2NMI-2 3HardFault 11SVCallconfigured by register SHPR2 14PendSVconfigured by register SHPR3 15SysTickconfigured by register SHPR3 16 External Interrupt (0) configured by register NVIC_IPRx ……… 47 External Interrupt (31) configured by register NVIC_IPRx Exceptions defined in Cortex-M0

Department of Electrical Engineering, National Taiwan Ocean University Exception Model – cont. ► Exception priorities and pre-emption –Lower numbers take higher precedence –If multiple exceptions have the same priority number, the pending exception with the lowest exception number takes precedence. –Only exceptions with a higher priority (lower priority number) can pre-empt an active exception.

Department of Electrical Engineering, National Taiwan Ocean University Context Saving & Restoring ► Key context saving and restoring –Using full-descending stack format (decremented immediately before storing, incremented after reading) –xPSR, ReturnAddress(), LR (R14), R12, R3, R2, R1, and R0 xPSR ReturnAddress LR r12 r3 r2 r1 r0 SP’ SP H Loaded into PC on exception return

Department of Electrical Engineering, National Taiwan Ocean University Cortex-M0 address map Code Typically ROM or flash memory, WT 0x – 0x1FFFFFFF Typically used for on-chip RAM, WBWA0x – 0x3FFFFFFF on-chip peripheral, XN0x – 0x5FFFFFFF 0x – 0x7FFFFFFF 0x – 0x9FFFFFFF 0xA – 0xBFFFFFFF 0xC – 0xDFFFFFFF system segment including the PPB, XN 0xE – 0xFFFFFFFF SRAM Peripheral System Note 1 : Event entry points (vectors), system control, and configuration are defined at physical addresses Note 2 : A multi-word access which crosses a 0.5GB address boundary is UNPREDICTABLE

Department of Electrical Engineering, National Taiwan Ocean University Setting in Keil Code region SRAM region Program entry point

Department of Electrical Engineering, National Taiwan Ocean University System Control Space (SCS) ► Consists of the following groups –CPUID space. –System control, configuration and status. –SysTick system timer –Nested Vectored Interrupt Controller (NVIC) 0xE000E xE000E00F Auxiliary Control register 0xE000E xE000E0FF System Timer 0xE000E xE000ECFF NVIC 0xE000ED00 - 0xE000ED8F System control and ID registers 0xE000EDF0 - 0xE000EEFF Debug control and configuration

Department of Electrical Engineering, National Taiwan Ocean University System Control Space – cont. AddressNameFunctionTypeReset Value 0xE000E008ACTLRAuxiliary Control RegisterR/W IMPLEMENTATION DEFINED 0xE000ED00CPUIDCPUID RegisterRO IMPLEMENTATION DEFINED 0xE000ED04ICSRInterrupt Control State RegisterR/W0x xE000ED08VTORVector Table Offset RegisterRO0x xE000ED0CAIRCR Application Interrupt/Reset Control Register R/Wbits [10:8] = ’ 000 ’ 0xE000ED10SCRSystem Control Register (optional)R/Wbits [4,2,1] = ’ 000 ’ 0xE000ED14CCRConfiguration and Control RegisterRObits [9,3] = ’ 1 ’ 0xE000ED1CSHPR2System Handler Priority Register 2R/WSBZ 0xE000ED20SHPR3System Handler Priority Register 3R/WSBZ 0xE000ED24SHCSRSystem Handler Control and State RegisterR/W0x xE000ED30DFSR DebugFault Status Register (Debug Extension only) R/W0x System control and ID register

Department of Electrical Engineering, National Taiwan Ocean University System Control Space – cont. ► Some registers are implementation defined and read-only –Ex : CPUID, VTOR ► Interrupt Control State Register (ICSR) –Generate system interrupt request in software manner. –NMI, PendSV and SysTick ► System Handler Priority Registers –Set up priority number of system interrupts SHPR2 : SVCall SHPR3 : SysTick and PendSV

Department of Electrical Engineering, National Taiwan Ocean University System Timer - SysTick ► SysTick provides a simple, 24-bit clear-on-write, decrementing, wrap-on- zero counter. ► When enabled, the timer will count down. When the counter transitions to zero, the COUNTFLAG status bit is set. ► The reference clock can be the core clock or an external clock source. 24-bit down count counter Reference clock CPU clock external clock SysTick request when counter reaches 0 Reload counter

Department of Electrical Engineering, National Taiwan Ocean University System Timer – cont. AddressNameFunctionTypeReset Value 0xE000E010SYST_CSRSysTick Control and StatusR/W0x xE000E014SYST_RVRSysTick Reload valueR/WUNKNOWN 0xE000E018SYST_CVRSysTick Current valueR/WUNKNOWN 0xE000E01CSYST_CALIBSysTick Calibration valueROIMP DEF System timer register

Department of Electrical Engineering, National Taiwan Ocean University System Timer – cont. ► SysTick Control and Status (SYST_CSR) –Enables counting and interrupt –Selects reference clock source ► SysTick Reload value (SYST_RVR) –Copied to current value register when counter reaches 0 ► SysTick Current value (SYST_CVR) –Keeps current counter value ► SysTick Calibration value (SYST_CALIB) –Defined by implementation

Department of Electrical Engineering, National Taiwan Ocean University NVIC (Nested Vectored Interrupt Controller) ► Upon stack based exception model –Restore registers to resume to normal execution automatically –Remove redundant PUSH/POP operations needed by traditional C-based ISRs. ► Benefits over traditional systems –Enhancing performance in low MHz systems –Provide deterministic response for late arrival and pre-emption –Achieve lower latency without state restore and save

Department of Electrical Engineering, National Taiwan Ocean University Tail Chaining Technology ► The processor state is automatically saved on interrupt entry, and restored on interrupt exit ► Fewer cycles than a software implementation, significantly enhancing performance in low MHz systems Traditional MCU NuMicro

Department of Electrical Engineering, National Taiwan Ocean University Late Arrival of Higher Priority Interrupts Traditional MCU NuMicro ► NVIC immediately fetches a new vector address to service the pending interrupt ► Provide deterministic response to these possibilities with support for late arrival and pre-emption

Department of Electrical Engineering, National Taiwan Ocean University Stack Pop Pre-emption ► Abandon a stack Pop if an exception arrives and service the new interrupt immediately. ► Achieve lower latency in a deterministic manner by pre-empting and switching to the second interrupt without completing the state restore and save Traditional MCU NuMicro

Department of Electrical Engineering, National Taiwan Ocean University Nested Vectored Interrupt Controller (NVIC) ► Supports up to 32 (IRQ[31:0]) discrete interrupts which can be either level-sensitive or pulse-sensitive. ► NVIC interrupts can be enabled/disabled, pended/un-pended and prioritized by setting NVIC control registers NVIC interrupt 0 : Interrupt 31 Interrupt number Cortex-M0 System interrupts Exception number Exception 1 Exception 2 Exception 47 Vector Table

Department of Electrical Engineering, National Taiwan Ocean University NVIC registers AddressNameFunctionTypeReset Value 0xE000E100NVIC_ISERIrq 0 to 31 Set-Enable RegisterR/W0x xE000E180NVIC_ICERIrq 0 to 31 Clear-Enable RegisterR/W0x xE000E200NVIC_ISPRIrq 0 to 31 Set-Pending RegisterR/W0x xE000E280NVIC_ICPRIrq 0 to 31 Clear-Pending RegisterR/W0x xE000E400NVIC_IPR0Irq 0 to 3 Priority RegisterR/W0x xE000E404NVIC_IPR1Irq 4 to 7 Priority RegisterR/W0x xE000E408NVIC_IPR2Irq 8 to 11 Priority RegisterR/W0x xE000E40CNVIC_IPR3Irq 12 to 15 Priority RegisterR/W0x xE000E410NVIC_IPR4Irq 16 to 19 Priority RegisterR/W0x xE000E414NVIC_IPR5Irq 20 to 23 Priority RegisterR/W0x xE000E418NVIC_IPR6Irq 24 to 27 Priority RegisterR/W0x xE000E41CNVIC_IPR7Irq 28 to 31 Priority RegisterR/W0x

Department of Electrical Engineering, National Taiwan Ocean University NVIC – cont. ► Interrupt Set-Enable and Clear-Enable Registers –NVIC_ISER : write 1 to enable interrupt –NVIC_ICER : write 1 to disable interrupt ► Interrupt Set-Pending and Clear-Pending Registers –NVIC_ISPR : write 1 to generate interrupt request –NVIC_ICPR : write 1 to remove interrupt request ► Interrupt Priority Registers –NVIC_IPR0 ~ NVIC_IPR7 –Each priority register can set up priority number of four interrupts

Department of Electrical Engineering, National Taiwan Ocean University Cortex-M0 Summary ► Cortex-M0 is always in privileged mode and supports Thumb instruction only. ► Supports key context saving and restoring –xPSR, return address, r14, r12, r3, r2, r1, r0 ► System address map is defined in advance. –Code, SRAM, Peripheral, System ► Contains SysTick and NVIC

Department of Electrical Engineering, National Taiwan Ocean University General Disclaimer The Lecture is strictly used for educational purpose. MAKES NO GUARANTEE OF VALIDITY ► The lecture cannot guarantee the validity of the information found here. The lecture may recently have been changed, vandalized or altered by someone whose opinion does not correspond with the state of knowledge in the relevant fields. Note that most other encyclopedias and reference works also have similar disclaimers.similar disclaimers No formal peer review ► The lecture is not uniformly peer reviewed; while readers may correct errors or engage in casual peer review, they have no legal duty to do so and thus all information read here is without any implied warranty of fitness for any purpose or use whatsoever. Even articles that have been vetted by informal peer review or featured article processes may later have been edited inappropriately, just before you view them.peer reviewfeatured article No contract; limited license ► Please make sure that you understand that the information provided here is being provided freely, and that no kind of agreement or contract is created between you and the owners or users of this site, the owners of the servers upon which it is housed, the individual Wikipedia contributors, any project administrators, sysops or anyone else who is in any way connected with this project or sister projects subject to your claims against them directly. You are being granted a limited license to copy anything from this site; it does not create or imply any contractual or extracontractual liability on the part of Wikipedia or any of its agents, members, organizers or other users. ► There is no agreement or understanding between you and the content provider regarding your use or modification of this information beyond the Creative Commons Attribution-Sharealike 3.0 Unported License (CC-BY-SA) and the GNU Free Documentation License (GFDL);Creative Commons Attribution-Sharealike 3.0 Unported License GNU Free Documentation License

Department of Electrical Engineering, National Taiwan Ocean University General Disclaimer Trademarks ► Any of the trademarks, service marks, collective marks, design rights or similar rights that are mentioned, used or cited in the lectures are the property of their respective owners. Their use here does not imply that you may use them for any purpose other than for the same or a similar informational use as contemplated by the original authors under the CC-BY- SA and GFDL licensing schemes. Unless otherwise stated, we are neither endorsed by nor affiliated with any of the holders of any such rights and as such we cannot grant any rights to use any otherwise protected materials. Your use of any such or similar incorporeal property is at your own risk. Personality rights ► The lecture may portray an identifiable person who is alive or deceased recently. The use of images of living or recently deceased individuals is, in some jurisdictions, restricted by laws pertaining to personality rights, independent from their copyright status. Before using these types of content, please ensure that you have the right to use it under the laws which apply in the circumstances of your intended use. You are solely responsible for ensuring that you do not infringe someone else's personality rights.personality rights