Freescale Cortex.m0.code - Density
Freescale Cortex.m0.code - Density
MCU’s
NXP LPC1100 Cortex M0
Oct 2009
Outline
Introduction
Conclusions
2
ARM Cortex-M Processors
Cortex-M family optimised for deeply embedded
– Microcontroller and low-power applications
3
ARM Cortex-M0 Processor
Thumb-2
– All processor operations can all be handled in ‘Thumb’ state
– Enables a performance optimised blend of 16/32-bit instructions
– Supported in all Cortex processors
Thumb®
Thumb instruction set upwards compatibility
5
Instruction set architecture
Based on 16-bit Thumb ISA from ARM7TDMI
– Just 56 instructions, all with guaranteed execution time
– 8, 16 or 32-bit data transfers possible in one instruction
Thumb Thumb-2
User assembly code, compiler generated System, OS
ADC ADD ADR AND ASR B NOP
6
Program registers r0
r1
r2
All registers are 32-bit wide r3
– Instructions exist to support 8/16/32-bit data
r4
r5
13 general purpose registers r6
– Registers r0 – r7 (Low registers) r7
– Registers r8 – r12 (High registers) r8
r9
r10
3 registers with special meaning/usage
– Stack Pointer (SP) – r13 r11
– Link Register (LR) – r14 r12
– Program Counter (PC) – r15 r13 (SP)
r14 (LR)
r15 (PC)
Special-purpose registers - xPSR
xPSR
7
Instruction behaviour
a = a * b; C code 15 0
8
Thumb instructions
9
Nested Vectored Interrupt Controller
NVIC enables efficient exception handling
– Integrated within the processor - closely coupled with the core
– Handles system exceptions & interrupts
10
Interrupt behaviour
r0
r1
r13 (SP)
r2
r3
r12 Push Stack
r14 (LR)
r15 (PC) Growth
xPSR
Memory
11
Writing interrupt handlers
Traditional approach ARM Cortex-M family
12
Software support for sleep modes
14
Code Size
15
Code size of 32 bits versus 16/8bit MCU’s
The instruction size of 8 bit MCU’s is not 8 bits
– 8051 is 8 to 24 bits
– PIC18 is 18 bits
– PIC16 is 16 bits
The instruction size of 16 bit MCU’s is not 16 bits
– MSP430 can be up to 32bits and the extended version can be up to 64 bits
– PIC24 is 24 bits
16
Code size of 32 bits versus 16/8bit MCU’s
17
16-bit multiply example
Consider an device with a 10-bit ADC
– Basic filtering of data requires a 16-bit multiply operation
– 16-bit multiply operation is compared below
19
What about Data ?
For 16 bit processors have issues with
– Long integers
– Floating point types
– Data transfers between processor registers and memory
20
What addressing modes?
16/8 bit processors are limited to 64K of space
– Data memory limited and segmented
– Requires banking or extensions to instruction set
– Memory pointers are extended
Require multiple instructions and registers
21
Code size increase due to paging
22
Code size increase for large memory model
(Extended program counter and Registers)
23
Code Size Performance
2.50
2.00
1.50
HC08
M0 using microlib
1.00
0.50
0.00
puwmod
bitmnp
pntrch
rspeed
canrdr
a2time
iirflt
aifirf
aiifft
24
Code Size Performance
M0 code size is on average 10% smaller than best MSP430 average
Code size for basic functions
350
MSP430
MSP430F5438
300
MSP430F5438 Large model
Cortex M0
250
Code Size (Bytes)
200
150
100
50
0
Math8bit
Math16bit
Math32bit
Matrix2dim8bit
Matrix2dim16
Matrixmult
Switch8bit
Switch16bit
25
Code Size Performance
M0 code size is 42% and 36% smaller than best MSP430 generic
1000
800 MathFloat
600 Firfilter
400
200
0
Cortex-M0
MSP430
MSP430F5438
MSP430F5438
Generic
large data
model
26
Code Size Performance
M0 code size is 30% smaller than MSP430F5438
Whet
7000
6000
Code Size (Bytes)
5000
4000
3000
2000
1000
0
MSP430
Generic
MSP430F5438
MSP430F5438
Cortex-M0
large data
model
27
What is CoreMark?
28
CoreMark Workload Features
Matrix manipulation allows the use of MAC and common math ops
Linked list manipulation exercises the common use of pointers
State machine operation represents data dependent branches
Cyclic Redundancy Check (CRC) is very common embedded function
Testing for:
– A processor’s basic pipeline structure
– Basic read/write operations
– Integer operations
– Control operations
29
Code Size Performance (CoreMark)
M0 code size is 16% smaller than generic MSP430
18000
16000
14000
Code Size (Bytes)
12000
10000
8000
6000
4000
2000
0
Generic MSP430 M0
30
Code Size Performance (CoreMark)
M0 code size is 53% smaller than PIC24
18000
16000
14000
Code Size (Bytes)
12000
10000
8000
6000
4000
2000
0
PIC24 M0
31
Code Size Performance (CoreMark)
M0 code size is 51% smaller than PIC18
18000
16000
14000
Code Size (Bytes)
12000
10000
8000
6000
4000
2000
0
PIC18 M0
32
Code Size Performance (CoreMark)
M0 code size is 49% smaller than Atmel AVR8
18000
16000
14000
Code Size (Bytes)
12000
10000
8000
6000
4000
2000
0
Atmel AVR8 Mega644 M0
33
Code Size Performance (CoreMark)
M0 code size is 44% smaller than Renesas H8
18000
16000
14000
Code Size (Bytes)
12000
10000
8000
6000
4000
2000
0
Renesas(H8) M0
34
Peripheral code
35
Speed Optimization effects
2.00 12000
10000
1.50
8000
CoreMark Score
1.00 6000
Code Size
4000
0.50
2000
0.00 0
t0 t1 t2 t3
36
Size Optimization effects
1.30 12000
1.25 10000
1.20 8000
CoreMark Score
1.15 6000
Code Size
1.10 4000
1.05 2000
1.00 0
s0 s1 s2 s3
37
Size Optimization effects
1.30 12000
1.25 10000
1.20 8000
CoreMark Score
1.15 6000
Code Size
1.10 4000
1.05 2000
1.00 0
s0 s1 s2 s3
38
What About Libraries
33% reduction using optimized Libs
NXP M0
39
Performance
40
Computation Performance
41
Computation Performance
uSec
42
Computation Performance
CoreMark Score
1.8
1.6
Coremark (Mark/sec)
1.4
1.2
1
0.8
0.6
0.4
0.2
0
PIC18 Renesas (8 AVR8 MSP430 M0
bit) ATMega644
43
Cost
44
Does the core size matter?
The M0 core is the smallest cortex core
About 1/3 of the M3 for similar configuration
Similar size to 8 bit cores
45
Core Size Matters
2.50
2.00
Normalized Cost
1.50
1.00
0.50
0.00
32 64 128 256 512
Memory Size
46
Tools
47
MCU Tool Solutions
Rapid Prototyping
Online Tool
48
NXP’s FIRST Low Cost Toolchain
49
LPCXpresso
LPCXpresso will provide end-to-end
solution from evaluation all the way to
product development
Attractive upgrade options to full blown
suites and development boards
LPCXpresso will change the perception
about NXP’s solution for tools
Key competition:
– Microchip MPLAB
– Atmel AVR Studio
LPC3154
51
Evaluation
LPC3154
The target board is very simple with one LED and a layout option for USB
Traces between the two boards can be cut, to allow SWD connection to any
customer target. (Eval target can be reconnected by jumpers)
52
Exploration
LPC13xx
LPC3154
Base board
53
Development
Customer’s own
LPC3154
board which
will use JTAG
Traces can be cut and the LPC13xx target board will out of the picture
Customers can then use the JTAG connection to download code into their own
application board using the same existing IDE and JTAG connector
Note: Customers can directly jump to this stage and use LPCXpresso for their complete
application development without ever having to upgrade
54
mbed LPC1768 Value Proposition
New users start creating applications in 60 seconds
Rapid Prototyping with LPC1700 series MCUs
– Immediate connectivity to peripherals and modules for prototyping
LPC1700-based system designs
– Providing developers with the freedom to be more innovative & productive
mbed C/C++ Libraries provide API-driven approach to coding
– High-level interfaces to peripherals enables rock-solid, compact code
– Built on Cortex Microcontroller Software Interface Standard (CMSIS)
Download compiled binary by saving to the mbed hardware
– Just like saving to a USB Flash Drive
Tools are online - there is nothing to configure, install or update, and
everything works on Windows, Mac or Linux
Hardware in a 40-pin 0.1" pitch DIP form-factor
– Ideal for solderless breadboard, stripboard and through-hole PCBs
55
First Experience – Hassle-Free Evaluation
No Installation!
56
mbed Technology
USB Drag ‘n’ Drop Programming Interface
► Nothing to Install: Program by saving binaries
► Works on Windows, Linux, Mac, without drivers
► Links through to mbed.org website
Online Compiler
► Nothing to Install: Browser-based IDE
► Best in class RealView Compiler in the back end
► No code size or production limitations
#include “mbed.h” High-level Peripheral Abstraction Libraries
Serial terminal(9,10);
AnalogIn temp(19); ► Instantly understandable APIs
int main() {
if(temp > 0.8)
terminal.printf(“Hot!”);
► Object-oriented hardware/software abstraction
}
► Enables experimentation without knowing MCU details
57
Example Beta Projects - Videos
Rocket Launch
– http://www.youtube.com/watch?v=zyY451Rb-50&feature=PlayList&p=000FD2855BEA7E90&index=11
Billy Bass
– http://www.youtube.com/watch?v=Y6kECR7T4LY
Voltmeter
– http://www.youtube.com/watch?v=y_7WxhdLLVU&feature=PlayList&p=000FD2855BEA7E90&index=8
Knight Rider
– http://www.youtube.com/watch?v=tmfkLJY-1hc&feature=PlayList&p=000FD2855BEA7E90&index=4
Scratch Pong
– http://www.youtube.com/watch?v=aUtYRguMX9g&feature=PlayList&p=000FD2855BEA7E90&index=5
58
More information
59
Rapid Prototyping
for Microcontrollers
60
What’s happening in Microcontrollers?
61
Rapid Prototyping
Rapid Prototyping helps industries create new products
– Control, communication and interaction increasingly define products
– Development cycles for microelectronics have not kept pace
62
mbed
Getting Started and Rapid Prototyping with ARM MCUs
– Complete Targeted Hardware, Software and Web 2.0 Platform
Rapid Prototyping
for Microcontrollers
High-level Peripheral APIs LPC Cortex-M MCU in a
Prototyping Form-Factor
63
mbed Audience
mbed’s focus on Rapid Prototyping has a broad appeal
64
Conclusion
LPC1100 Family Based on the Cortex-M0 core
– There are many users of 8 and 16 bit microcontrollers that are reluctant to
use 32 bit architectures citing either overkill or complexity.
– The LPC ARM Cortex-M0 family provides a microcontroller that is very low
power, has better real-time performance than microcontrollers of lower bit
width and provides a bridge to the full spectrum of the LPC families.
65
66