Professional Documents
Culture Documents
TM
External Use
Become an ARM Accredited Engineer!
Overview
TM
External Use 2
What is the AAE program
TM
External Use 3
Characteristics of the AAE program
Computer-
Based Tests
(Series of
Multiple Exams Multiple Choice Industry-Wide
Questions) Standard
Subject, Scope,
Difficulty Level Same exam
throughout the world
TM
External Use 4
How do Individuals Benefit?
TM
External Use 5
How do Employers Benefit
TM
External Use 6
Prometric – A Market Leader in CBT
• AVAILABLE NOW –
www.prometric.com/arm
TM
External Use 7
What to expect in the AAME exam?
System Startup
5%
Software
Optimization
10%
Architectural
Software 35%
Development
30%
Software Debug
Implementation 13%
7%
TM
External Use 8
Prepare for the Test
Materials on
Self-study
Read AAE Syllabus ARM Infocentre
Document + many books
Instructor-led
ARM training,
training
ARM is committed to ATCs and AATPs
growing the range of
options available to help
test-takers prepare for
Further/higher AAUPs and other
AAE accreditation education universities
TM
External Use 9
Architecture
TM
External Use 10
Development of the ARM Architecture
v4 v5 v6 v7
SIMD Instructions Thumb-2
Halfword and Improved Multi-processing NEON™
signed halfword ARM/Thumb v6 Memory architecture TrustZone®
/ byte support Interworking Unaligned data support Virtualization
System mode CLZ Architecture Profiles
Thumb Saturated arithmetic Extensions v7-A (Applications): NEON
instruction set DSP multiply- Thumb-2 (v6T2)
accumulate TrustZone (v6Z) v7-R (Real-time): Hardware divide
instructions Multicore (v6K)
Thumb only (v6-M) v7-M (Microcontroller): Hardware
divide, Thumb-only
External Use 11
ARMv7 Architecture Profiles
TM
External Use 12
ARM Cortex-M Processors
TM
External Use 13
ARMv7-M Profile Overview
TM
External Use 14
ARMv7-M Register Set
• Registers R0-R7
R0
R1 − Accessible to all instructions
R2
R3 • Registers R8-R12
R4
− Accessible to a few 16-bit instructions
R5
R6 − Accessible to all 32-bit instructions
R7
R8 • R13 is the stack pointer (SP)
R9
− V7-M cores have two banked versions
R10
R11 • R14 is the link register (LR)
R12
• R15 is the program counter (PC)
R13
R15
(SP)
(PC)
• xPSR (Program Status Register)
R14 (LR)
− Not explicitly accessible
R15 (PC)
− Saved to the stack on an exception
PSR − Subsets available as APSR, IPSR, and EPSR
TM
External Use 15
xPSR – Program Status Register
31 28 27 26 25 24 23 16 15 10 7 0
TM
External Use 16
Stacks
TM
External Use 17
Processor Mode Usage
ARM Processor
Application Code
Thread Reset
Exception Mode
Entry
Exception
Return
Exception Code
Interrupts
Handler Faults
Mode
TM
External Use 18
Exception Handling
• Exception types
− Reset
− Non-maskable Interrupts (NMI)
− Faults
− PendSV
− SVCall
− External Interrupt
− SysTick Interrupt
• Exceptions processed in Handler mode
− Uses privileged mode
• Interrupt handling
− Interrupts are a sub-class of exception
− Automatic save and restore of processor registers ({PC, xPSR, R0-R3, R12, R14)
− Allows handler to be written entirely in ‘C’
TM
External Use 19
Instruction Set Support
TM
External Use 20
Instruction Set Examples:
• Data Processing:
MOV r2, r5 ; r2 = r5
ADD r5, #0x24 ; r5 = r5 + 36
ADD r2, r3, r4, LSL #2 ; r2 = r3 + (r4 * 4)
LSL r2, #3 ; r2 = r2 * 8
MOVT r9, #0x1234 ; upper halfword of r9 = #0x1234
MLA r0, r1, r2, r3 ; r0 = (r1 * r2) + r3
• Memory Access:
STRB r2, [r10, r1] ; store lower byte in r2 at
address {r10 + r1}
LDR r0, [r1, r2, LSL #2] ; load r0 with data at address
{r1 + r2 * 4}
• Program Flow:
BL <label> ; PC relative branch to <label>
; location, and return address
; stored in LR (r14)
TM
External Use 21
System Address Map
0xFFFFFFFF
System
Device
Device
RAM
RAM
Peripheral
SRAM
Code 512MB
0x00000000
TM
External Use 22
Memory bus structure
• The Bus Matrix partitions memory access via the AHB and PPB
buses
FFFFFFFF
System (XN)
E0100000
APB Debug Components
E0040000
CM3 Instruction SCS + NVIC
E0000000
Core Data
External Peripheral
1 GB
Bus Matrix INTERNAL PPB
A0000000
with SYSTEM AHB
SYSTEM AHB External RAM
Debug Bit- Bander
Debug ICODE AHB 1 GB
Aligner
and Patch DCODE AHB EX
60000000
Peripheral ½GB
BB
40000000
RAM
½GB
EX+BB
20000000
EX – Code execution support Code Space
HX
½GB
HX – High performance code execution 00000000
BB – Bit banding
TM
External Use 23
Instruction and Data Alignment
• Instruction alignment
− Thumb instructions must be 16-bits wide and halfword-aligned
− Thumb-2 instructions are 16 or 32-bits wide and are halfword-aligned
• Data alignment
− Core can be configured for optional unaligned data accesses
• Instruction fetches in ARM Cortex-M Profile are always little-endian
• Data accesses can support both big and little-endian
− Cortex-M3 is switchable at reset
− System Control Space accesses are always little-endian
TM
External Use 24
Power Management
TM
External Use 25
Exceptions
TM
External Use 26
Exceptions Overview
• The ARM v7-M (and v6-M) exception architecture is very different from
other ARM architectures
• Designed for microcontroller applications
− Support for many interrupt sources
− Efficient handling of nested interrupts
− Flexible interrupt architecture (highly configurable)
− Built in RTOS support
• Main Features
− Nested Vector Interrupt Controller (NVIC)
− Micro-coded architecture handles the “dirty work”
No software overhead for Interrupt Entry/Exit and Interrupt Nesting
− Only one mode and one stack for all exception handling
Handler mode / Main stack
− Easy to program
All exception handlers may be coded in “C”
TM
External Use 27
Interrupt Overheads
IRQ1
IRQ2
ARM7TDMI
Push ISR 1 Pop Push ISR 2 Pop
Interrupt Handling
26 Cycles 16 Cycles 26 Cycles 16 Cycles
TM
External Use 28
External Interrupts
INTNMI
INTISR[0] ……
… NVIC
… Cortex-Mx
INTISR[N] Processor Core
TM
External Use 29
Micro-coded Interrupt Mechanism
TM
External Use 30
Exception Priorities Overview
TM
External Use 31
Vector Table for ARMv7-M
Address Exception #
• First entry contains initial Main SP 0x40 + 4*N External N 16 + N
• All other entries are addresses for exception … … …
handlers
0x40 External 0 16
− Must always have LSBit = 1 (for Thumb)
0x3C SysTick 15
• Table has up to 496 external interrupts
0x38 PendSV 14
− Implementation-defined
− Maximum table size is 2048 bytes
0x34 Reserved 13
TM
External Use 32
Reset Behavior
Main
5
4
Reset Handler
External Use 33
Coming Out of Reset
TM
External Use 34
Interrupt Service Routine Entry
• When receiving an interrupt the processor will finish the current instruction
for most instructions
− To minimize interrupt latency, the processor can take an interrupt during the
execution of a multi-cycle instruction - see next slide
• Processor state automatically saved to the current stack
− 8 registers are pushed: PC, R0-R3, R12, LR, xPSR
− Follows ARM Architecture Procedure Calling Standard (AAPCS)
• During (or after) state saving the address of the ISR is read from the Vector
Table
• Link Register is modified for interrupt return
• First instruction of ISR executed
− For Cortex-M3 or Cortex-M4 the total latency is normally 12 cycles, however,
interrupt late-arrival and interrupt tail-chaining can improve IRQ latency
• ISR executes from Handler mode with Main stack
TM
External Use 35
Internal Exceptions
• SysTick Timer
− Provides system heart-beat for RTOS (or custom program executive)
− Periodic interrupt drives system task scheduling
− Better than a standard Timer Interrupt
Integrated into the NVIC
Does not vary between vendor implementation and Cortex-M families
• System Service Call (SVC)
− Similar to “SVC” instruction on other ARM cores
− Allows non-privileged software to make system calls
RTOS services requests from non-privileged mode
Provides protection to important system functionality
Examples: Open Serial Port, Remap Memory, Enter Low Power Mode, etc.
• Pended System Call (PendSV)
− Operates with SVC to ease RTOS development
− Intended to be an interrupt for RTOS use
TM
External Use 36
Fault Exceptions on v7-M
TM
External Use 37
Advanced Features and Debug
TM
External Use 38
Motivation: Memory Protection
Memory
Privileged OS
modes code + data
OS
ARMxyz
TM
External Use 39
Memory Protection Overview
External Use 40
v7-M Bit-banding
TM
External Use 41
v7-M Bit-banding
31MB
31MB
TM
External Use 42
ARM Cortex-M3/M4 Debug Features
TM
External Use 43
Cortex-M3/M4 Debug Access Paths
Cortex-M3
Core Bus AHB - Internal Private Peripheral Bus
Matrix
APB - External Private Peripheral Bus
AHB-
SW/J-DP
AP
DAP
TM
External Use 44
Flash Patch and Breakpoint Unit (FPB)
• Flash Patching
− Allows runtime patching of firmware
Remaps reads from the Code space to System space using a Patch Table
− Total of 8 addresses may be patched
6 instruction comparators (for instruction fetches from Code space)
2 literal comparators (for literal data loads from Code space)
− Only reads are patched
Writes will be performed as normal
− Intended Usage
ROM-based designs (costly fix)
Firmware field upgrades
• Hardware Breakpoints – maximum of 6
− The 6 instruction comparators can return a BKPT to halt the core
− Instruction comparators are shared with Flash Patch functionality
If 3 instructions are flash patched, only 3 hardware breakpoints are available
TM
External Use 45
Data Watchpoint and Trace (DWT)
TM
External Use 46
Instrumentation Trace Macrocell (ITM)
TM
External Use 47
Physical Interfaces
TM
External Use 48
Software
TM
External Use 49
Introduction
TM
External Use 50
Keil MDK: ARM Compiler
• Compiler compile/assemble
TM
External Use 51
Language Support
• Language compliance
− Default mode supports several common extensions
− Strict mode enforces compliance with language standard: --strict
− GNU mode offers partial support for GCC extensions: --gnu
TM
External Use 52
Variable types supported
TM
External Use 53
Optimization Levels
• Select optimization for code size or execution speed with -Ospace (default) or -
Otime
• Use -g or --debug to generate source level debug information
TM
External Use 54
Selecting an Architecture or Core
• Each new version of the ARM Architecture typically supports extra instructions and
models of operation
• Implementation of an architecture version may vary between cores
− Use the most specific setting you can when compiling
• Inform the compiler of the architecture or processor
− The default CPU setting is ARM7TDMI (Architecture 4T)
− Either specify an architecture version, or a specific core
--cpu 7-M (Do not prefix with a ‘v’)
--cpu Cortex-M3
• Some examples of features the compiler and libraries can take advantage of:
− UDIV and SDIV (7-M and 7-R)
− REV (v6) can be used to reverse byte endianness
− Unaligned memory access (v6)
• When using the Cortex-M3 it is essential to specify 7-M or Cortex-M3 to ensure the
correct (Thumb only) libraries are used
TM
External Use 55
CMSIS Structure
TM
External Use 56
Using CMSIS-CORE
To use the CMSIS-CORE the following files are added to the embedded
application:
Startup File startup_<device>.s with reset handler and exception vectors
System Configuration Files system_<device>.c and system_<device>.h with
general device configuration (clock setup)
Device Header File <device.h> gives access to processor core and all peripherals
External Use 57
More Information
TM
External Use 58
Next Steps
• Find out more about the program, the test and how to prepare for it:
Visit www.arm.com/aae
• Recommended Reading
− Joseph Yiu – The Definitive Guide to the Cortex-M3 and Cortex-M4
Processors. ISBN 0124080820
− ARMv7m Architecture Reference Manual
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0403c/index.html
− ARM Cortex-M Generic User Guide
http://infocenter.arm.com/help/topic/com.arm.doc.dui0553a/index.html
TM
External Use 59