ARM Cortex-M4 Architecture and Instruction Set 1: Architecture Overview

Similar documents
EE 308: Microcontrollers

ARM Cortex core microcontrollers 3. Cortex-M0, M4, M7

ELC4438: Embedded System Design ARM Cortex-M Architecture II

The ARM Cortex-M0 Processor Architecture Part-1

ARM Cortex-M4 Architecture and Instruction Set 4: The Stack and subroutines

EE 354 Fall 2015 Lecture 1 Architecture and Introduction

Introduction to ARM LPC2148 Microcontroller

AN Migrating to the LPC1700 series

Interconnects, Memory, GPIO

ARM Cortex-M4 Architecture and Instruction Set 3: Branching; Data definition and memory access instructions

ARM Cortex-A9 ARM v7-a. A programmer s perspective Part1

LPC4370FET256. Features and benefits

ARM Architecture and Assembly Programming Intro

ERRATA SHEET INTEGRATED CIRCUITS. Date: 2008 June 2 Document Release: Version 1.6 Device Affected: LPC2468. NXP Semiconductors

EE4144: ARM Cortex-M Processor

ARM Embedded Systems: ARM Design philosophy, Embedded System Hardware, Embedded System Software

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

Getting Started With the Stellaris EK-LM4F120XL LaunchPad Workshop. Version 1.05

ERRATA SHEET INTEGRATED CIRCUITS. Date: July 7, 2008 Document Release: Version 1.8 Device Affected: LPC2148

Microcontrollers. Microcontroller

Hello, and welcome to this presentation of the STM32L4 power controller. The STM32L4 s power management functions and all power modes will also be

Product Technical Brief S3C2412 Rev 2.2, Apr. 2006

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

COEN-4720 Embedded Systems Design Lecture 3 Intro to ARM Cortex-M3 (CM3) and LPC17xx MCU

Diploma in Embedded Systems

Embedded Systems. Software Development & Education Center. (Design & Development with Various µc)

ECE 471 Embedded Systems Lecture 2

OUTLINE. STM32F0 Architecture Overview STM32F0 Core Motivation for RISC and Pipelining Cortex-M0 Programming Model Toolchain and Project Structure

The industrial technology is rapidly moving towards ARM based solutions. Keeping this in mind, we are providing a Embedded ARM Training Suite.

ARM Cortex-M4 Architecture and Instruction Set 2: General Data Processing Instructions

Lecture 5: Computing Platforms. Asbjørn Djupdal ARM Norway, IDI NTNU 2013 TDT

STM32 Journal. In this Issue:

ERRATA SHEET INTEGRATED CIRCUITS. Date: July 9, 2007 Document Release: Version 1.6 Device Affected: LPC2148

MICROPROCESSOR BASED SYSTEM DESIGN

Product Technical Brief S3C2413 Rev 2.2, Apr. 2006

NXP Microcontrollers Selection Guide

Hello, and welcome to this presentation of the STM32L4 System Configuration Controller.

ARM architecture road map. NuMicro Overview of Cortex M. Cortex M Processor Family (2/3) All binary upwards compatible

Designing with STM32F2x & STM32F4

STM32 Cortex-M3 STM32F STM32L STM32W

STM32F429 Overview. Steve Miller STMicroelectronics, MMS Applications Team October 26 th 2015

STM32F7 series ARM Cortex -M7 powered Releasing your creativity

ARM Cortex-M4 Programming Model

acret Ameya Centre for Robotics & Embedded Technology Syllabus for Diploma in Embedded Systems (Total Eight Modules-4 Months -320 Hrs.

Hercules ARM Cortex -R4 System Architecture. Processor Overview

Chapter 4. Enhancing ARM7 architecture by embedding RTOS

Measuring Interrupt Latency

Solution to the Problems and Questions

ECE 598 Advanced Operating Systems Lecture 4

Overview of Microcontroller and Embedded Systems

2-Oct-13. the world s most energy friendly microcontrollers and radios

Advanced Microcontrollers Grzegorz Budzyń Extras: STM32F4Discovery

Copyright 2016 Xilinx

RDB1768 Development Board User Manual

Hello, and welcome to this presentation of the STM32 Reset and Clock Controller.

Chapter 15. ARM MCUs Architecture, Programming and Development Tools

Cortex M4-based LPC4300 The first asymmetric multi-core MCU for the industry

ATmega128. Introduction

AVR Microcontrollers Architecture

Design and Implementation Interrupt Mechanism

8051 Microcontroller

STM32F7 series ARM Cortex -M7 powered Releasing your creativity

SYLLABUS UNIT - I 8086/8088 ARCHITECTURE AND INSTRUCTION SET

AVR XMEGA Product Line Introduction AVR XMEGA TM. Product Introduction.

AK-STM32-ETH Development Board


Lab 1 Introduction to Microcontroller

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

UM LPC3180 User Manual. Document information. LPC3180; ARM9; 16/32-bit ARM microcontroller User manual for LPC3180

NXP AN11528 sensor Application note

Welcome to this presentation of the STM32 direct memory access controller (DMA). It covers the main features of this module, which is widely used to

ARM Cortex core microcontrollers

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

ELEC 3040/3050 Lab Manual Lab 2 Revised 8/20/14. LAB 2: Developing and Debugging C Programs in MDK-ARM for the STM32L100RC Microcontroller

STM32 MICROCONTROLLER

LPC15xx. 1. General description. 2. Features and benefits

Product Series SoC Solutions Product Series 2016

GUJARAT TECHNOLOGICAL UNIVERSITY

Microprocessor and Microcontroller question bank. 1 Distinguish between microprocessor and microcontroller.

Infineon C167CR microcontroller, 256 kb external. RAM and 256 kb external (Flash) EEPROM. - Small single-board computer (SBC) with an

L2 - C language for Embedded MCUs

Programming in the MAXQ environment

UM LPC2101/02/03 User manual. Document information

NXP Unveils Its First ARM Cortex -M4 Based Controller Family

PIC Microcontroller Introduction

Computer Organization and Assembly Language (CS-506)

AND SOLUTION FIRST INTERNAL TEST

TEVATRON TECHNOLOGIES PVT. LTD Embedded! Robotics! IoT! VLSI Design! Projects! Technical Consultancy! Education! STEM! Software!

ECE254 Lab3 Tutorial. Introduction to MCB1700 Hardware Programming. Irene Huang

ARM Processors ARM ISA. ARM 1 in 1985 By 2001, more than 1 billion ARM processors shipped Widely used in many successful 32-bit embedded systems

AT-501 Cortex-A5 System On Module Product Brief

CN310 Microprocessor Systems Design

STM32 F0 Value Line. Entry-level MCUs

LPC2148 DEV BOARD. User Manual.

ECE 471 Embedded Systems Lecture 2

Main Memory (RAM) Organisation

Product Technical Brief S3C2440X Series Rev 2.0, Oct. 2003

Universität Dortmund. ARM Architecture

User Manual. LPC-StickView V3.0. for LPC-Stick (LPC2468) LPC2478-Stick LPC3250-Stick. Contents

Unlocking the Potential of Your Microcontroller

Transcription:

ARM Cortex-M4 Architecture and Instruction Set 1: Architecture Overview M J Brockway January 25, 2016

UM10562 All information provided in this document is subject to legal disclaimers. NXP B.V. 2014. All rights reserved. Block diagram NXP Semiconductors UM10562 Chapter 1: Introductory information 1.5 Simplified block diagram JTAG interface Ethernet PHY LCD USB bus or interface panel tranceiver Xtalin Xtalout RST General Purpose I/O ports Ethernet registers USB registers SPI Flash Interface LCD registers CRC engine TEST/DEBUG INTERFACE ARM Cortex-M4 with FPU I-code bus D-code bus System bus General Purpose DMA controller Ethernet 10/100 MAC Multilayer AHB Matrix LCD panel interface USB OTG/ Host/ Device clocks and controls EEPROM Up to 4 kb Flash Accelerator SRAM Up to 96 kb Boot ROM 8 kb Static / Dynamic Memory Controller clock generation, power control, and other system functions Flash Up to 512 kb 26-bit addr 32-bit data APB slave group 0 UARTs 0 & 1 SSP1 CAN 1 & 2 I 2 C 0 & 1 Capture/Match timer 0 & 1 PWM0 & 1 12-bit ADC Pin connect block GPIO interrupt control Analog comparators APB slave group 1 UARTs 2, 3, & 4 SSP0 & 2 I 2 S I 2 C 2 Capture/Match timer 2 & 3 SD card interface DAC Motor control PWM Quadrature Encoder i/f External interrupts Watchdog oscillator Event Inputs ALARM Vbat 32 khz oscillator ultra-low power regulator Windowed Watchdog Event Monitor/ Recorder Real Time Clock Backup registers (20 bytes) System control Note: - Orange shaded peripheral blocks support General Purpose DMA. - Yellow shaded peripheral blocks include a dedicated DMA controller. RTC Power Domain 120229 Fig 1. LPC408x/407x simplified block diagram User manual Rev. 3 12 March 2014 10 of 947

Block diagram This block diagram is reproduced from the LPC408x/407x User Manual, published by NXP Semiconductors, the makers of the LPC4088 microcontroller (CPU) used in our kit. There are a few TLAs (three-letter acronyms) - FPU floating-point unit DMA direct memory access Controller AHB advanced high-performance bus APB advanced peripheral bus SSP synchoronous serial port SPI serial peripheral interface - another serial bus I 2 C inter-integrated circuit - yet another serial bus PWM pulse-width modulation I 2 S inter-ic sound ADC, DAC, CAN...

Block diagram EEPROM electronically erasible, programmable read-only memory. Flash is a type of EEPROM. SRAM static random-access memory: fast; retains contents as long as powered-up; but expensive. Uses for key high performance purposes: cache, stack,... DRAM dynamic random-access memory: slower, and capacitor-based: needs regular charge top-up; but cheaper. Used for the bulk of RAM.

Programmer s model Ref: Generic User Guide section 2.1 Processor modes main stack - running application software. Limited access to some instructions, system timer. System is in this mode immediately after reset. handler mode - handling as exception. Returns to thread mode after all exceptions handled. Stacks full descending: Stack pointer is decremented when an item is pushed on; the stack grows downwards Two stacks: main and process; a special register controls which. Programmer s model: next slide (ref GUG 2.1.)

Programmer s model Registers... R0-R12 32-bit general-purpose registers for data operations. Avoid using higher regsiters for applicaton programming! R13 the stack pointer: main or process stack depending on setting in CONTROL register. R14 is the link register(lr): stores the return information for subroutines, function calls, and exceptions. R15 is the program counter: stores the address of the next instruction to be fetched. PSR The program status register contains information about status of last operationn. Bits 27-31 are the condition codes; the ones we shall be most concerned with are N : the last operation produced an arithmetically negative result Z : the last operation produced a zero result C : the last operation produced a carry (or borrow) V : the last operation produced an arithmetic overflow

Programmer s model Registers (ctd) CONTROL manages privilege level of the current instruction, and which of the two stacks to use. Exceptions and interrupts NVIC The processor and the nested vectored interrupt controller manage prioritized handling. Data types 32-bit words, 16-bit halfwords, 8-bit bytes. Can be big- or little-endian; instruction memory and private peripheral but (PPB) accesses are always little-endian.

Memory model Ref: Generic User Guide sec 2.2; With 32-bit addressing, the memory space is 4 Gb.

Memory model code 00000000-1FFFFFFF is where executible code goes. On-chip FLASH. Data can go here, but not recommended. SRAM 20000000-3FFFFFFF is primarily for application data, but code can go here. peripherals 40000000-5FFFFFFF - on-chip peripherals external RAM 60000000-9FFFFFFF - eg DDR, FLASH, LCD external device A0000000-DFFFFFFF - external peripherals private peripher bus E0000000-E00FFFFF vendor-specific E0100000-FFFFFFFF

Memory model - bit-band aliasing A bit-band operation allows a single load/store operation to access a single bit in the memory; Normal method: load register with a 32-bit value from RAM address; OR or XOR it with a mask, or AND with MASK store register value to RAM address. Bit-band method - provided for some addresses: Each bit of the address is mapped from a bit-band alias address; Writing a 0 or 1 to the alias address changes just that bit of the real address. Fast only two operations rather than three; Atomic

Memory model - bit-band aliasing Example - set bit 3 at address 0x20000000: LDR R1, =0x20000000 LDR R0,[R1] ORR.W R0,#0x8 STR R0,[R1] The bit-band alias for bit 3 of address 0x20000000 is 0x2200000C so all we have to do is LDR R1, =0x2200000C LDR R0, #1 STR R0, [R1]

Memory model - bit-band aliasing Only some addresses have bit-band aliases Addresses in the 32 Mb range 22000000-23FFFFF are aliases for the bits of the 1 Mb of data 20000000-200FFFFF. SRAM region Addresses in the 32 Mb range 42000000-43FFFFF are aliases for the bits of the 1 Mb of data 40000000-400FFFFF Peripherals region These addresses are normally used for memory-mapped I/O, where we need to read and set each bit as efficiently as possible. The very first blinky example you saw last semester used bit-band aliased addresses. See the Generic User Guide, subsection 2.2.5.

Cortex-M4 Image of a Program From low to high memory,... 1. Interrupt vector table - addresses of interrupt and exception handlers 2. C startup routine 3. Application code and data 4. C library code On reset, the CPU 1. Reads initial stack pointer address 2. Reads interrupt vector for reset 3. The reset handler branches to start of application program 4. The program executes...

Introducing Cortex-M4 Machine Instructions The size of most instructions is 32 bits (4 bytes) or 16 bits (2 bytes), comprising a THUMB-2 operation code and sometimes and additional operand. The program as loaded into RAM is thus and array of 32-bit words. The address of the n th instruction (counting from 0) is therefore the base address of the loaded program + 32n. Shall use ARM assembly language as a human-readable version of these instructions. The following is a simple program: simpler than Hello world, as it does not do any I/O. It simply uses registers R0, R1 to compute 10 + 9 + 8 +... + 1, leaving the result in register R1.

Cortex-M4 Machine Instructions - simple example PRESERVE8 ; Indicate the code here preserve ; 8 byte stack alignment THUMB ; Indicate THUMB code is used AREA.text, CODE, READONLY ; Start of CODE area EXPORT main ENTRY main FUNCTION ; initialize registers MOV r0, #10 ; Starting loop counter value MOV r1, #0 ; starting result ; Calculating 10+9+8+...+1... loop ADD r1, r0 ; R1 = R1 + R0 SUBS r0, #1 ; Decrement R0, update flag ( S suffix) BNE loop ; If result not zero jump to loop ; Result is now in R1 deadloop B deadloop ; Infinite loop ENDFUNC END ; End of file

Simple example: pseudocode main function: Put value 10 in register 0 Put value 0 in register 1 Repeat: Add contents of R0 to R1, leaving result in R1; Subtract 1 from contents of R0, updating condition codes according to the result; Check condition codes: if Z not set, repeat, else drop out of loop Forever run on the spot (branch to self)

Simple example with machine code and relative addresses 1 00000000 PRESERVE8 2 00000000 ; 8 byte stack alignment 3 00000000 THUMB 4 00000000 AREA 5 00000000 EXPORT main 6 00000000 ENTRY 7 00000000 main FUNCTION 8 00000000 ; initialize registers 9 00000000 F04F 000A MOV r0, #10 10 00000004 F04F 0100 MOV r1, #0 11 00000008 ; Calculating 10+9+8+...+1 12 00000008 loop 13 00000008 4401 ADD r1, r0 14 0000000A 3801 SUBS r0, #1 15 0000000C D1FC BNE loop 16 0000000E ; Result is now in R1 17 0000000E deadloop 18 0000000E E7FE B deadloop 19 00000010 ENDFUNC 20 00000010 END

References UM10562.pdf: The LPC408x/407x User Manual DUI0553A cortex m4 dgug.pdf: The Cortex M4 Generic User Guide Both these documents are linked to the home page of the module, in the group Resources for the LPC4088. The Generic User Guide is well worth reading in conjunction with these lecture slides and in general provides a fairly readable technical but not-too-technical introduction. The user manual is a good reference document.