810 likes | 993 Views
LPCXpresso Workshop B. Vasu Dev vasu@easyarm.com. Enabling the ARM Learning in INDIA. AGENDA ARM Introduction Development Tools Setup Hardware Detail and Schematics ARM Cortex Programming Using CMSIS ( Create New Projects for Cortex ) Application Development.
E N D
LPCXpresso Workshop B. Vasu Dev vasu@easyarm.com Enabling the ARM Learning in INDIA
AGENDA • ARM Introduction • Development Tools Setup • Hardware Detail and Schematics • ARM Cortex Programming • Using CMSIS ( Create New Projects for Cortex ) • Application Development Enabling the ARM Learning in INDIA
ARM INTRODUCTION Enabling the ARM Learning in INDIA
What is ARM? • The ARM is a 32-bit reduced instruction set computer (RISC) instruction set architecture (ISA) developed by ARM Holdings. • ARM also known as Advance RISC Machine Enabling the ARM Learning in INDIA
Why ARM? • Simplicity is the key philosophy behind the ARM design • RISC machine with small instruction set and consequently a small gate count. • High Performance • Low power consumption • Small amount of silicon die area. • Open Source Development Tools Enabling the ARM Learning in INDIA
Where is ARM? Enabling the ARM Learning in INDIA
History • Founded in November 1990 Spun out of Acorn Computers • Designs the ARM range of RISC processor cores • Licenses ARM core designs to semiconductor partners who fabricate and sell to their customers. ARM does not fabricate silicon itself • Also develop technologies to assist with the design-in of the ARM architecture Software tools, boards, debug hardware, application software, bus architectures, peripherals etc Enabling the ARM Learning in INDIA
ARM Core Family Enabling the ARM Learning in INDIA
ARM Core Family T: Thumb D: On-chip debug support M: Enhanced multiplier I: Embedded ICE hardware T2: Thumb-2 S: Synthesizable code E: Enhanced DSP instruction set J: JAVA support, Jazelle Z: Should be TrustZone? F: Floating point unit H: Handshake, clockless design for synchronous or asynchronous design Enabling the ARM Learning in INDIA
ARM Core Family ARM processor core + cache + MMU = ARM CPU cores ARM6 → ARM7 – 3-stage pipeline – Keep its instructions and data in the same memory system – Thumb 16-bit compressed instruction set – On-chip Debug support, enabling the processor to halt in response to a debug request – Enhanced Multiplier, 64-bit result – Embedded ICE hardware, give on-chip breakpoint and watchpoint support Enabling the ARM Learning in INDIA
ARM Core Family ARM8 → ARM9 → ARM10 ARM9 – 5-stage pipeline (130 MHz or 200MHz) – Using separate instruction and data memory ports ARM 10 (1998. Oct.) – High performance, 300 MHz – Multimedia digital consumer applications – Optional vector floating-point unit ARM11 (2002 Q4) –8-stage pipeline – Addresses a broad range of applications in the wireless, consumer, networking and automotive segments –Support media accelerating extension instructions –Can achieve 1GHz & Support AXI Enabling the ARM Learning in INDIA
ARM Architecture Versions Version 1 – The first ARM processor, developed at Acorn Computers Limited 1983-1985 – 26-bit address, no multiply or coprocessor support Version 2 – Sold in volume in the Acorn Archimedes and A3000 products – 26-bit addressing, including 32-bit result multiply and coprocessor Version 2a – Coprocessor 15 as the system control coprocessor to manageCache – Add the atomic load store (SWP) instruction Version 3 – First ARM processor designed by ARM Limited (1990) – ARM6 (macro cell), ARM60 (stand-alone processor) ARM600 (an integrated CPU with on-chip cache, MMU, write buffer) ARM610 (used in Apple Newton) – 32-bit addressing, separate CPSR and SPSRs – Add the undefined and abort modes to allow coprocessor emulation and virtual memory support in supervisor mode Enabling the ARM Learning in INDIA
ARM Architecture Versions Version 3M – Introduce the signed and unsigned multiply and multiplyaccumulate instructions that generate the full 64-bit result Version 4 – Add the signed, unsigned half-word and signed byte load and store instructions – Reserve some of SWI space for architecturally defined operation – System mode is introduced Version 4T – 16-bit Thumb compressed form of the instruction set is introduced Version 5T – Introduced recently, a superset of version 4T adding the BLX, CLZ and BRK instructions Version 5TE Add the signal processing instruction set extension Enabling the ARM Learning in INDIA
ARM Architecture Versions Version 6 – Media processing extensions (SIMD) • 2x faster MPEG4 encode/decode • 2x faster audio DSP – Improved cache architecture • Physically addressed caches • Reduction in cache flush/refill • Reduced overhead in context switches – Improved exception and interrupt handling • Important for improving performance in real-time tasks – Unaligned and mixed-endian data support • Simpler data sharing, application porting and saves memory Enabling the ARM Learning in INDIA
ARM Architecture Versions Version7 Enabling the ARM Learning in INDIA
Development of theARM Architecture 5TE Improved ARM/Thumb Interworking CLZ 4 Jazelle Java bytecodeexecution 5TEJ Halfword and signed halfword / byte support System mode 1 ARM9EJ-S ARM926EJ-S SA-110 Saturated maths DSP multiply-accumulate instructions 2 SA-1110 ARM7EJ-S ARM1026EJ-S 3 6 SIMD Instructions Multi-processing V6 Memory architecture (VMSA) Unaligned data support ARM1020E Thumb instruction set 4T XScale Early ARM architectures ARM7TDMI ARM9TDMI ARM9E-S ARM720T ARM940T ARM966E-S ARM1136EJ-S Enabling the ARM Learning in INDIA
ARM Cores & Arch Ver Enabling the ARM Learning in INDIA
ARM CORTEX The ARM Cortex family includes processors based on the three distinct profiles of the ARMv7 architecture.The A profile for sophisticated, high-end applications running open and complex operating systemsThe R profile for real-time systemsThe M profile optimized for cost-sensitive and microcontroller applications Enabling the ARM Learning in INDIA
Why ARM Cortex ? • 1. Developed for embedded systems • 2. High performance with low dynamic power • Harvard Architecture • 30% performance improvement over ARM7TDMI • Single-cycle multiply and hardware division • Atomic Bit manipulation • Best code density • Thumb-2 brings 32-bit performance with 16-bit code density • Deterministic • Interrupt controller inside the core, 6-cycle latency 6 CPU cycles wake up time from Low Power Mode • Improved debug features • Serial Wire debug and JTAG • 2 data watchpoints, 8 hardware breakpoints Enabling the ARM Learning in INDIA
ARM Cortex PipeLine - Cortex CPU executes instruction in single cycle. And this is achieved with the three stage pipeline. - One instruction being executed the next is being deecoded and the third is being fetch from the memory. - Speculative fetch is performed for the branch instruction so both conditional instructions are available for execution without any performance hit.. - The worst case is the indirect branch where the speculative fetch can not be made and need to flush the pipeline. Pipeline is the key to the overall performance of the Cortex CPU. Enabling the ARM Learning in INDIA
Three Stage Pipeline The pipeline is used to overcome the delay caused by instruction fetching and decoding before execution. Enabling the ARM Learning in INDIA
Three Stage Pipeline Fetch – The instruction is fetched from memory and placed in the instruction pipeline Decode – The instruction is decoded and the data path control signals prepared for the next cycle Execute – The register bank is read, an operand shifted, the ALU result generated and written back into destination register The three stage pipeline has hardware independent stages that execute one instruction while decoding a second and fetching a third. PC runs 8 bytes ahead of current execution instruction since it holds the address of the fetching instruction but not the current execution instruction. 0x4000 LDR PC,[PC,#4] results PC => 0x400C not 0x4004 Enabling the ARM Learning in INDIA
Processor Modes • Register R13-R15 having special function within the Cortex CPU. • Register R13 allows the CPU to operates in Two Operating modes[Thread & Handler]. • Each mode having it's own stack and space. • Two stack is called Main stack and process stack. Enabling the ARM Learning in INDIA
Registers Enabling the ARM Learning in INDIA
Exception Handling • When an exception occurs, the ARM: • Copies CPSR into SPSR_<mode> • Sets appropriate CPSR bits • Change to ARM state • Change to exception mode • Disable interrupts (if appropriate) • Stores the return address in LR_<mode> • Sets PC to vector address To return, exception handler needs to: • Restore CPSR from SPSR_<mode> • Restore PC from LR_<mode> Enabling the ARM Learning in INDIA
Exception Handling • The NVIC supports nesting (stacking) of interrupts, allowing an interrupt to be serviced earlier by exerting higher priority. It also supports dynamic reprioritisation of interrupts. Priority levels can be changed by software during run time. Enabling the ARM Learning in INDIA
Instruction Set Enabling the ARM Learning in INDIA
Instruction Set • ARM’s implement two types of instruction sets • 32-bit ARM Instruction Set • 16-bit Thumb Instruction Set Enabling the ARM Learning in INDIA
ARM (32bit) IS Enabling the ARM Learning in INDIA
ARM (32bit) IS • Every ARM (32 bit) instruction is conditionally executed. • The top four bits are ANDed with the CPSR condition codes, If they do not matched the instruction is executed as NOP • The AL condition is used to execute the instruction irrespective of the value of the condition code flags. • By default, data processing instructions do not affect the condition code flags but the flags can be optionally set by using “S”. Ex: SUBS r1,r1,#1 • Conditional Execution improves code density and performance by reducing the number of forward branch instructions. Normal Conditional CMP r3,#0 CMP r3,#0 BEQ skip ADDNE r0,r1,r2 ADD r0,r1,r2skip Enabling the ARM Learning in INDIA
Condition Codes Each ARM (32bit) Instruction can be prefixed with any of the following conditional code. Enabling the ARM Learning in INDIA
Condition Codes Examples: Set the flags, then use various condition codes if (a==0) x=0;if (a>0) x=1; CMP r0,#0MOVEQ r1,#0MOVGT r1,#1 Enabling the ARM Learning in INDIA
Branch instructions BBasic branch instruction used to jump forward or backward of up to 32 MB. BL Branch and Link instruction jumps to the destination and stores a return address in R14 (Link Register). BX, BLX Branch, Brach Link and Exchange. This swaps the instruction sets from ARM to THUMB and vice versa while jumping. BXJ Branch and change to Jazelle state. Enabling the ARM Learning in INDIA
Data Processing Inst. Arithmetic: ADD ADC SUB SBC RSB RSC Logical: AND ORR EOR BIC Comparisons: CMP CMN TST TEQ Data movement: MOV MVN Enabling the ARM Learning in INDIA
Multiply Instructions MUL, MLA MULL, MLAL Enabling the ARM Learning in INDIA
Data Transfer Inst. Simple Data Transfer Inst. LDR STR Word LDRB STRB Byte LDRH STRH Halfword LDRSB Signed byte load LDRSH Signed halfword load Load / Store Multiple Registers LDM STM Enabling the ARM Learning in INDIA
Swap Instruction Are also called as semaphore instructions SWP R12, R10, [R9] ; load R12 from address R9 and ; store R10 to address R9 SWPB R3, R4, [R8] ; load byte to R3 from address R8 and ; store byte from R4 to address R8 SWP R1, R1, [R2] ; Exchange value in R1 and address in R2 Enabling the ARM Learning in INDIA
Miscellaneous Inst. Software Interrupt Causes an exception trap to the SWI hardware vector The SWI handler can examine the SWI number to decide what operation has been requested. By using the SWI mechanism, an operating system can implement a set of privileged operations which applications running in user mode can request. Ex. SWI #3 PSR Transfer Instructions MRS and MSR allow contents of CPSR / SPSR to be transferred to / from a general purpose register. MRS{<cond>} Rd,<psr>; Rd = <psr> MSR{<cond>} <psr[_fields]>,Rm; <psr[_fields]> = Rm Enabling the ARM Learning in INDIA
2. Development Tools Set Up Enabling the ARM Learning in INDIA
Development Tools Used. • LPCXpresso is development platform from NXP. • Eclipse based IDE, A GNU C Compiler, • A Linker and Libraries and GDB debugger. • Emulator. Enabling the ARM Learning in INDIA
LPCExpresso setup Enabling the ARM Learning in INDIA
LPCExpresso setup Enabling the ARM Learning in INDIA
LPCExpresso setup Enabling the ARM Learning in INDIA
Eclipse IDE Enabling the ARM Learning in INDIA Options used for Project Development Source Code Work Space
Debug Mode Debug and Programming
1. Hardware and Schematics Enabling the ARM Learning in INDIA
LPC1343 Enabling the ARM Learning in INDIA
NGX Base Board Enabling the ARM Learning in INDIA
NGX Base Board Enabling the ARM Learning in INDIA