ARM Cortex-M3 Introduction. ARM University Relations



Similar documents
Overview of the Cortex-M3

The ARM Architecture. With a focus on v7a and Cortex-A8

Cortex -M3. Technical Reference Manual. Revision: r1p1. Copyright 2005, 2006 ARM Limited. All rights reserved. ARM DDI 0337E

Migrating Application Code from ARM Cortex-M4 to Cortex-M7 Processors

Cortex -M0 Devices. Generic User Guide. Copyright 2009 ARM Limited. All rights reserved. ARM DUI 0497A (ID112109)

Digitale Signalverarbeitung mit FPGA (DSF) Soft Core Prozessor NIOS II Stand Mai Jens Onno Krah

Cortex -M3 Devices. Generic User Guide. Copyright 2010 ARM. All rights reserved. ARM DUI 0552A (ID121610)

Chapter 13. PIC Family Microcontroller

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-12: ARM

Keil Debugger Tutorial

Software based Finite State Machine (FSM) with general purpose processors

ARM Cortex STM series

Application Note 179. Cortex -M3 Embedded Software Development. Released on: March Copyright All rights reserved.

An Introduction to the ARM 7 Architecture

AN LPC1700 timer triggered memory to GPIO data transfer. Document information. LPC1700, GPIO, DMA, Timer0, Sleep Mode

ARM Microprocessor and ARM-Based Microcontrollers

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: EC Microprocessor & Microcontroller Year/Sem : II/IV

ES_LPC4357/53/37/33. Errata sheet LPC4357/53/37/33. Document information

Exception and Interrupt Handling in ARM

PM0056 Programming manual

Embedded Systems on ARM Cortex-M3 (4weeks/45hrs)

STM32 F-2 series High-performance Cortex-M3 MCUs

Using the CoreSight ITM for debug and testing in RTX applications

Von der Hardware zur Software in FPGAs mit Embedded Prozessoren. Alexander Hahn Senior Field Application Engineer Lattice Semiconductor

Embedded Component Based Programming with DAVE 3

Cortex-A9 MPCore Software Development

Microprocessor & Assembly Language

Lab Experiment 1: The LPC 2148 Education Board

Architectures, Processors, and Devices

Applications Development on the ARM Cortex -M0+ Free On-line Development Tools Presented by William Antunes

Am186ER/Am188ER AMD Continues 16-bit Innovation

Designing a System-on-Chip (SoC) with an ARM Cortex -M Processor

BEAGLEBONE BLACK ARCHITECTURE MADELEINE DAIGNEAU MICHELLE ADVENA

Interrupt handling. Andrew N. Sloss

Building A RISC Microcontroller in an FPGA

ARM Architecture. ARM history. Why ARM? ARM Ltd developed by Acorn computers. Computer Organization and Assembly Languages Yung-Yu Chuang

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-17: Memory organisation, and types of memory

Five Families of ARM Processor IP

ARM Ltd 110 Fulbourn Road, Cambridge, CB1 9NJ, UK.

Motor Control using NXP s LPC2900

AN10866 LPC1700 secondary USB bootloader

Application Note 195. ARM11 performance monitor unit. Document number: ARM DAI 195B Issued: 15th February, 2008 Copyright ARM Limited 2007

Hello, and welcome to this presentation of the STM32L4 reset and clock controller.

How To Port From The Ark7Tdmi To The Corporum3 Processor

ARM Processors and the Internet of Things. Joseph Yiu Senior Embedded Technology Specialist, ARM

Hardware accelerated Virtualization in the ARM Cortex Processors

Embedded Software development Process and Tools:

National CR16C Family On-Chip Emulation. Contents. Technical Notes V

Smartphone Quick-Jack Solution FASTER TO PRODUCT FASTER TO MARKET

System Considerations

Freescale Semiconductor, I

Keil C51 Cross Compiler

COMPUTER HARDWARE. Input- Output and Communication Memory Systems

ARM-Architektur. Toni Reber Redacom AG, 2560 Nidau.

How To Design A Single Chip System Bus (Amba) For A Single Threaded Microprocessor (Mma) (I386) (Mmb) (Microprocessor) (Ai) (Bower) (Dmi) (Dual

EE8205: Embedded Computer System Electrical and Computer Engineering, Ryerson University. Multitasking ARM-Applications with uvision and RTX

UNIT 4 Software Development Flow

Serial Communications

Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University

DS1104 R&D Controller Board

Microtronics technologies Mobile:

Atmel Norway XMEGA Introduction

Microcontrollers. -Definition, Basics and Trends. Anders Pettersson. FAE Manager Nordic and Baltic

7a. System-on-chip design and prototyping platforms

EE361: Digital Computer Organization Course Syllabus

MICROPROCESSOR AND MICROCOMPUTER BASICS

CHAPTER 4 MARIE: An Introduction to a Simple Computer

Definitions and Documents

Building Blocks for PRU Development

ARM Accredited Engineer AAE Syllabus. Document number: ARM AEG 0052C Copyright ARM Limited 2012

Embedded Development Tools

Going Linux on Massive Multicore

System Design Issues in Embedded Processing

Hardware and Software Requirements

Technical Note. Micron NAND Flash Controller via Xilinx Spartan -3 FPGA. Overview. TN-29-06: NAND Flash Controller on Spartan-3 Overview

An introduction to nxpusblib. March 2012

Cortex -A15. Technical Reference Manual. Revision: r2p0. Copyright 2011 ARM. All rights reserved. ARM DDI 0438C (ID102211)

OpenSPARC T1 Processor

UM LPC2210/2220 User manual. Document information

Silabs Ember Development Tools

The new 32-bit MSP432 MCU platform from Texas

Lab 1 Course Guideline and Review

USB 3.0 Connectivity using the Cypress EZ-USB FX3 Controller

PART B QUESTIONS AND ANSWERS UNIT I

Freescale Semiconductor, Inc. Product Brief Integrated Portable System Processor DragonBall ΤΜ

CodeWarrior Development Studio for Microcontrollers Version 10.x Profiling and Analysis Tools Users Guide

Timer, Interrupt, Exception in ARM

AN4664 Application note

Intel StrongARM SA-110 Microprocessor

Designed & Developed By: Ms. Nidhi Agarwal. Under the Guidance of: Dr. SRN Reddy, Associate Professor, CSE. Computer Science & Engineering Department

8051 MICROCONTROLLER COURSE

CSC 2405: Computer Systems II

Chapter 6, The Operating System Machine Level

Chapter 1 Lesson 3 Hardware Elements in the Embedded Systems Chapter-1L03: "Embedded Systems - ", Raj Kamal, Publs.: McGraw-Hill Education

13. Publishing Component Information to Embedded Software

StrongARM** SA-110 Microprocessor Instruction Timing

Lesson 16 Analog-to-Digital Converter (ADC)

The Advanced JTAG Bridge. Nathan Yawn 05/12/09

PowerPC 405 GP Overview

Transcription:

ARM Cortex-M3 Introduction ARM University Relations 1

Agenda Cortex-M3 Overview v7-m Architecture/Programmers Model Data Path and Pipelines Tools and mbed Platform 2

What s Happening in Microcontrollers? Microcontrollers are getting cheap 32-bit ARM Cortex-M3 Microcontrollers @ $1 Some microcontrollers sell for as little as $0.65 Microcontrollers are getting powerful Lots of processing, memory, I/O in one package Floating-point is even available in some! Microcontrollers are getting interactive Internet connectivity, new sensors and actuators LCD and display controllers are common Creates new opportunities for microcontrollers 3

ARM Cortex-M3 Processor NVIC 1-240 Interrupts 8-256 Priorities I ARM Cortex-M3 Core D ETM Instruction Trace TPIU (5-pins) Trace Port DAP JTAG/SWD MPU ITM Instrumentation Trace Trace Port Serial-Wire Viewer (1-pin) FPB DWT Data Trace BKPT Bus Matrix Code Buses System Bus to Flash to Stack SRAM to Code SRAM to Peripherals 4

ARM Cortex-M3 Microcontroller 18 x 32-bit registers Excellent compiler target Reduced pin count requirements Efficient interrupt handling Power management Efficient debug and development support features Breakpoints, Watchpoints, Flash Patch support, Instruction Trace Strong OS support User/Supervisor model OS support features Designed to be fully programmed in C (even reset, interrupts and exceptions) 5

ARM Cortex-M3 Microcontroller ARMv7M Architecture No Cache - No MMU Debug is optimized for microcontroller applications Vector table contains addresses, not instructions DIV instruction Interrupts automatically save/restore state Exceptions programmed in C (No Coprocessor 15 - All registers are memory-mapped) Interrupt controller is part of Cortex-M3 macrocell Fixed memory map Bit-banding Non-Maskable Interrupt (NMI) Only one processor status reg Thumb-2 processing core Mix of 16 and 32 bit instructions for very high code density Gives complete Thumb compatibility 6

ARM and Thumb Performance 30000 25000 Dhrystone 2.1/sec @ 20MHz 20000 15000 10000 5000 ARM Thumb 0 32-bit 16-bit 16-bit with 32-bit stack Memory width (zero wait state) 7

The Thumb-2 instruction set Variable-length instructions ARM instructions are a fixed length of 32 bits Thumb instructions are a fixed length of 16 bits Thumb-2 instructions can be either 16-bit or 32-bit Thumb-2 gives approximately 26% improvement in code density over ARM Thumb-2 gives approximately 25% improvement in performance over Thumb 8

Agenda Cortex-M3 Overview v7-m Architecture/Programmers Model Data Path and Pipelines Tools and mbed Platform 9

Cortex-M3 Register Set Very compiler friendly Load/Store Architecture 32-bit registers Flexible register scheme Linear 32-bit address space Main r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 sp lr r15 (pc) xpsr sp Process 10

Program Status Register 31 28 27 26 25 24 23 16 15 10 7 0 N Z C V Q IT T IT/ICI ISR Number One Status Register consisting of APSR - Application Program Status Register ALU flags IPSR - Interrupt Program Status Register Interrupt/Exception No. EPSR - Execution Program Status Register IT field If/Then block information ICI field Interruptible-Continuable Instruction information xpsr Composite of the 3 PSRs Stored on the stack on exception entry 11

An Example AMBA System High Performance ARM processor APB UART High Bandwidth External Memory Interface AHB APB Bridge Timer Keypad High-bandwidth on-chip RAM DMA Bus Master PIO High Performance Pipelined Burst Support Multiple Bus Masters Low Power Non-pipelined Simple Interface 12

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again. The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupt ed. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again. Memory Map Very simple linear 4GB memory map The Bus Matrix partitions memory access via the AHB and PPB buses CM3 Core Debug Debug Instruction Data Bus Matrix with Bit- Bander Aligner and Patch APB INTERNAL PPB SYSTEM SYSTEMAHB AHB ICODE AHB DCODE AHB System Debug Components SCS + NVIC External Peripheral External RAM Peripheral RAM Code Space FFFFFFFF E0100000 E0040000 E0000000 1 GB A0000000 1 GB 60000000 ½GB 40000000 ½GB 20000000 ½GB 00000000 13

NXP LPC1311/13/42/43 Block Diagram 14

NXP LPC1311/13/42/43 Memory Map 15

Processor Privilege ARM Cortex-M3 Supervisor Handler Mode Privileged OS Aborts Interrupts Reset System Call (SVCall) Undefined Instruction User Thread Mode Non-Privileged Application code Memory Instructions & Data 16

Memory Protection Unit (MPU) MPU provides access control for various memory regions Zero Latency Memory Protection 8 register-stored regions Same regions used for instructions and data Minimum region size 32 Bytes (max 4GB) No address translation or page tables Configured via memory-mapped control registers 17

Cortex-M3 Bit Banding Traditional Method of Atomic Manipulation 0 0 0 0 0 0 0 0 Read byte from SRAM 0x02000000 Mask and Modify Bit Element x x x x x 1 x x 0x02000000 0 0 0 0 0 1 0 0 Write byte to SRAM 0x02000000 18

Cortex-M3 Bit Banding Writes to a word address in the bit band alias affect a single bit in the bit band region The write is translated to an atomic read-modify-write by the Cortex-M3 bus matrix Bit 0 of the stored register is written to the appropriate bit Word alias 32MB Bit band alias Physical bit 31MB 1MB Bit band region 32MB Bit band alias 31MB 1MB Bit band region 19

Conditional Execution If Then (IT) instruction added (16 bit) Up to 3 additional then or else conditions maybe specified (T or E) Makes up to 4 following instructions conditional ITTET EQ Inst 1 Inst 2 Inst 3 Inst 4 MOVEQ ADDEQ SUBNE ORREQ Any normal ARM condition code can be used 16-bit instructions in block do not affect condition code flags Apart from comparison instruction 32 bit instructions may affect flags (normal rules apply) Current if-then status stored in CPSR Conditional block maybe safely interrupted and returned to Must NOT branch into or out of if-then block 20

Interrupt Handling One Non-Maskable Interrupt (INTNMI) supported 1-240 prioritizable interrupts supported Interrupts can be masked Implementation option selects number of interrupts supported Nested Vectored Interrupt Controller (NVIC) is tightly coupled with processor core Interrupt inputs are active HIGH INTNMI 1-240 Interrupts INTISR[239:0] NVIC Cortex-M3 Processor Core Cortex-M3 21

Exception Handling Reset NMI Faults Hard Fault Memory Manage Bus Fault Usage Fault SVCall Debug Monitor PendSV SysTick Interrupt External Interrupt 22

Power Management Multiple sleep modes supported Controlled by NVIC Sleep Now Wait for Interrupt/Event instructions Sleep On Exit Sleep immediately on return from last ISR Deep Sleep Long duration sleep, so PLL can be stopped Exports additional output signal SLEEPDEEP Cortex-M3 system is clock gated in all sleep modes Sleep signal is exported allowing external system to be clock gated also NVIC interrupt Interface stays awake Wake-Up Interrupt Controller (WIC) External wake-up detector allows Cortex-M3 to be fully powered down Effective with State-Retention / Power Gating (SRPG) methodology 23

Cortex-M3 Debug Single stepping ITM (Instrumentation Trace Module) Support for instrumented code Like printf debugging, but single cycle writes to ITM module can be exported via serial interface Optional ETM (Embedded Trace Module) which provides instruction trace Access to all memory and registers via Debug Access Port (DAP) Profiling Support Helps you optimize your code A hardware triggered PC-sampler is provided by the Cortex-M3 core Flash patch / Breakpoints 6 instruction comparators, ARMv5T BKPT instruction is supported 2 literal comparators Allows flash code to be remapped into SRAM or system address space Data Watchpoint and Trace (DWT) that implements 4 h/w watchpoints 24

Agenda Cortex-M3 Overview v7-m Architecture/Programmers Model Data Path and Pipelines Tools and mbed Platform 25

Cortex-M3 Datapath I_HRDATA Instruction Decode D_HADDR Address Register Address Incrementer Write Data Register Read Data Register D_HWDATA D_HRDATA B I_HADDR Address Incrementer Address Register Register Bank A Writeback Mul/Div Barrel Shifter ALU ALU INTADDR 26

Cortex-M3 Pipeline Cortex-M3 has 3-stage fetch-decode-execute pipeline Similar to ARM7 Cortex-M3 does more in each stage to increase overall performance 1 st Stage - Fetch 2 nd Stage - Decode 3 rd Stage - Execute AGU Address Phase & Write Back Data Phase Load/Store & Branch Fetch (Prefetch) Instruction Decode & Register Read Multiply & Divide Write Branch forwarding & speculation Branch Shift ALU & Branch Execute stage branch (ALU branch & Load Store Branch) 27

Optimal Pipelining Cycle Operation ADD SUB ORR AND ORR EOR 1 2 3 4 5 6 7 8 9 F D E F D E F D E F D E F D E F D E F - Fetch D - Decode E - Execute All operations here are on registers (single cycle execution) In this example it takes 6 clock cycles to execute 6 instructions Clock cycles per Instruction (CPI) = 1 28

Branch Pipeline Example Cycle Address Operation 0x8000 BX r5 0x8002 SUB 0x8004 ORR 0x8FEC AND 0x8FEE ORR 0x8FF0 EOR 1 2 3 4 5 6 7 8 9 F D E F D F F D E F D E F D E F - Fetch D - Decode E Execute It takes 3 cycles to complete the branch Worst case scenario indirect branch taken 29

LDR Pipeline Example Cycle Operation ADD SUB LDR AND ORR EOR 1 2 3 4 5 6 7 8 9 F D E F D E F D Ea Ed F D S E F S D E F D E F - Fetch D - Decode E Execute S - Stall Ea LDR address phase Ed LDR data phase In this example it takes 7 clock cycles to execute 6 instructions Clock cycles per Instruction (CPI) = 1.2 The read cycle must complete on the bus before the LDR instruction can complete since there is only one writeback port in the register file 30

STR-STR Pipeline Example Cycle Operation ADD SUB STR STR ORR EOR 1 2 3 4 5 6 7 8 9 F D E F D E F D Ea Ed F D Ea Ed F D E F D E F - Fetch D - Decode E Execute S - Stall Ea Execute / STR address phase Ed STR data phase Store buffer allows STR instruction to finish before store cycle completes on the bus Back-to-back STR instructions pipeline on the AHB-Lite bus - Also works for LDR-STR-LDR-STR 31

Agenda Cortex-M3 Overview v7-m Architecture/Programmers Model Data Path and Pipelines Tools and mbed Platform 32

RVMDK Software Development Tools Includes ARM macro assembler, compilers (ARM RealView C/C++ Compiler, Keil CARM Compiler, or GNU compiler), ARM linker, Keil uvision Debugger and Keil uvision IDE Keil uvision Debugger accurately simulates on-chip peripherals (I 2 C, CAN, UART, SPI, Interrupts, I/O Ports, A/D and D/A converters, PWM, etc.) Evaluation Version 16K byte object code + 16K data limitation Some linker restrictions such as base addresses for code/constants GNU tools provided are not restricted in any way http://www.keil.com/demo/ 33

RVMDK Software Development Tools 34

Cortex-M3 Development Platforms 35

Rapid Prototyping Rapid Prototyping helps industries create new products Control, communication and interaction increasingly define products Development cycles for microelectronics have not kept pace 3D Moulding 36 3D Printing 2D/3D Design Web Frameworks

mbed Getting Started and Rapid Prototyping with ARM MCUs Complete Targeted Hardware, Software and Web 2.0 Platform Dedicated Developer Web Platform Lightweight Online Compiler http://mbed.org Rapid Prototyping for Microcontrollers High-level Peripheral APIs 37 Cortex-M3 MCU in a Prototyping Form-Factor

mbed Motor Controller Example #include "mbed.h DigitalOut leftfwd(p16); DigitalOut leftrev(p17); PwmOut pwm(p21); AnalogIn pot(p20); int main(){ pwm.period_ms(1); while(1){ float potmod = pot - 0.5; if (potmod >= 0){ leftfwd = 1; leftrev = 0; pwm=((1.8 * potmod) + 0.1); } else { leftfwd = 0; leftrev = 1; pwm = fabs((1.8 * potmod) - 0.1); } } } 38

Documentation ARM v7-m Architecture Reference Manual (ARM v7-m ARM) Cortex-M3 Technical Reference Manual (TRM) ARM Debug Interface V5 Architecture Spec (ADIv5) The Definitive Guide To The ARM Cortex-M3 by Joseph Yiu (Elsevier) 39

University Resources http://www.arm.com/support/university/ university@arm.com http://www.mbed.org/ http://www.keil.com/ 40

Fin 41