You are on page 1of 52

LPCXPRESSO HANDS ON

By Daniel Widyanto
September 2010
Contents

LPCXpresso Introduction
LPCXpresso Layout
Importing Project
Creating New Project
Exporting Project
LPCXpresso Tricks
– Generate Intel Hex, binary, and adding checksum
– View disassembled code

Debugging Blinky
– View core registers value
– View Timer value
2
LPCXpresso Introduction

3
LPCXpresso Introduction

(* )

Evaluation Product Development

4
LPCXpresso Introduction

Getting it:
– IDE: http://lpcxpresso.code-red-tech.com/LPCXpresso/
– Boards: Please ask your NXP representative

Support:
– Code examples / FAQ / Schematic: http://ics.nxp.com/support/lpcxpresso/
– Forum: http://knowledgebase.nxp.com/lpcxpresso.php

Installation and registration:
– Follow the steps on
http://ics.nxp.com/support/documents/microcontrollers/pdf/lpcxpresso.getting.started.pdf

Upgrade option
– http://www.code-red-tech.com/purchase.php?
– USD 1 for each 1KByte of JTAG download capability

5
LPCXpresso Layout

6
LPCXpresso Layout
1

2

3

7
LPCXpresso Layout

8
LPCXpresso Projects:
Importing Project

9
Importing Project

2

3
1

10
LPCXpresso Projects:
Creating New Project

11
Creating New Project

1

2

12
Creating New Project

3

4

13
LPCXpresso Projects:
Exporting Project

14
Exporting Project

2

3
1

15
LPCXpresso Tricks

16
LPCXpresso Tricks:
Generate Intel Hex, Binary, and Adding
Checksum
1

2

17
LPCXpresso Tricks:
Generate Intel Hex, Binary, and Adding
Checksum
3

5

4

6

18
LPCXpresso Tricks:
Generate Intel Hex, Binary, and Adding
Checksum
To generate Intel HEX file:
– arm-none-eabi-size ${BuildArtifactFileName}; arm-none-
eabi-objcopy -O ihex ${BuildArtifactFileName} $
{BuildArtifactFileBaseName}.hex ;
To generate plain binary file:
– arm-none-eabi-size ${BuildArtifactFileName}; arm-none-
eabi-objcopy -O binary ${BuildArtifactFileName} $
{BuildArtifactFileBaseName}.bin ;
To generate checksum-ed binary file*:
– arm-none-eabi-size ${BuildArtifactFileName}; arm-none-
eabi-objcopy -O binary ${BuildArtifactFileName} $
{BuildArtifactFileBaseName}.bin ; checksum -p $
{TargetChip} -d ${BuildArtifactFileBaseName}.bin;

– Checksum is needed for to indicate valid user code.
19
LPCXpresso Tricks:
View Disassembled Code

1

2

3

20
Debugging Blinky

21
Debugging Blinky

1

3

2

4 OR

22
Debugging Blinky

1
2

3

4

23
Debugging Blinky

OR

1
2

3

24
Debugging Blinky

1
2

3

25
26
LPCXPRESSO HANDS ON
By Daniel Widyanto
September 2010

1
Contents

LPCXpresso Introduction
LPCXpresso Layout
Importing Project
Creating New Project
Exporting Project
LPCXpresso Tricks
– Generate Intel Hex, binary, and adding checksum
– View disassembled code

Debugging Blinky
– View core registers value
– View Timer value
2

2
LPCXpresso Introduction

3

3
LPCXpresso Introduction

(* )

Evaluation Product Development

4

• What is LPCXpresso ?
• NXP's low-cost fully integrated development tool platform for the LPC MCU
family
• As an end-to-end solution for creating applications all the way from initial
evaluation to production

• What does it offer ?
• Simplified Eclipse-based IDE (128KB download limit)
• GNU toolchain with optimized libraries
• Low-cost target board with integrated JTAG/SWD debugger

• Linux version is also available

4
LPCXpresso Introduction

Getting it:
– IDE: http://lpcxpresso.code-red-tech.com/LPCXpresso/
– Boards: Please ask your NXP representative

Support:
– Code examples / FAQ / Schematic: http://ics.nxp.com/support/lpcxpresso/
– Forum: http://knowledgebase.nxp.com/lpcxpresso.php

Installation and registration:
– Follow the steps on
http://ics.nxp.com/support/documents/microcontrollers/pdf/lpcxpresso.getting.started.pdf

Upgrade option
– http://www.code-red-tech.com/purchase.php?
– USD 1 for each 1KByte of JTAG download capability

5

The LPCXpresso forum is supported by CodeRed FAEs. Please forward your
LPCXpresso questions directly to LPCXpresso forum (IDE hang, JTAG not detected,
MCU cannot be stopped, etc)

5
LPCXpresso Layout

6

6
LPCXpresso Layout
1

2

3

7

The LPCXpresso working area is divided into three major blocks:
1. Menu and Toolbar
2. Workspace area
3. Status bar

The LPCXpresso has many panes / views to show different functions of the IDE that can
be put inside the workspace area
Here’s some of the pane / view names and function:
• Project Explorer View: The ‘Project Explorer’ gives you a view of all the projects in
your current ‘Workspace’. A ‘Workspace’ is a collection of projects that are stored in
a single Workspace Directory on your computer.
• Editor: To modify and saving the source code as well as setting breakpoints in debug
mode.
• Console View: The Console View displays status information on compiling and
debugging, as well as program output.
• Problem View: The Problem View shows all compiler errors and will navigate the
Editor View to the error location.
• Quick Start View: To display fast links to commonly used features.

TODO: Try to rearrange your workspace according to your taste

7
LPCXpresso Layout

8

To display the views, use Window -> Show View.

TODO: Close all views and open : Project Explorer, Console, Quickstart. Rearrange
according to your taste

8
LPCXpresso Projects:
Importing Project

9

9
Importing Project

2

3
1

10

Importing project is useful if you want to import the source code from other parties without
losing the project’s configuration (compiler settings, debugger settings, etc)

1. Choose ‘File’ menu -> ‘Import..’
2. Choose ‘General’ -> ‘Existing Projects into Workspace’
3. If the project file is in archive format (eg. *.zip), you can use ‘Select archive file’.
Otherwise, you can import the whole directory into your workspace with ‘Select root
directory’
• For demo purpose, download the CMSIS from
‘C:\nxp\lpcxpresso_3.5\Examples\NXP\LPC1000\LPC11xx\1114examples
.zip’
• Only select the CMSIS package
1. Click ‘Finish’ once done

For archive file, you could pack several project files into single archive and restore it all of
them at once or select it.

10
LPCXpresso Projects:
Creating New Project

11

11
Creating New Project

1

2

12

1. Use ‘Quickstart’ -> ‘Start here’ -> ‘New project…’ -> ‘NXP LPC1100 C Project’
2. Fill the name of the project: LPC1114_Demo.
3. Click ‘Next’

12
Creating New Project

3

4

13

1. Select the MCU that you will use. This will be used as JTAG settings, linker and
startup file generation.
2. Tick the ‘Use CMSIS’ then click ‘Next’. CMSIS will provide you with basic LPC11xx
header files to access registers and basic core functions (such as setting up the PLL)
3. Click ‘Next’

13
LPCXpresso Projects:
Exporting Project

14

14
Exporting Project

2

3
1

15

Exporting project is useful if you want to send / save the source code without losing the
project’s configuration (compiler settings, debugger settings, etc)

1. Choose ‘File’ menu -> ‘Export..’
2. Choose ‘General’ -> ‘Archive File’
3. Select the project that you want to save into archive file, select the location and file
name of the archive file, and also select the archiving compression method (*.zip or
*.tar)
4. Click ‘Finish’ once done

For archive file, you could pack several project files into single archive and restore it all of
them at once or select it.

15
LPCXpresso Tricks

16

16
LPCXpresso Tricks:
Generate Intel Hex, Binary, and Adding
Checksum
1

2

17

1. Right click at the project name in ‘Project Explorer’ pane.
2. Select ‘Properties’ and click

17
LPCXpresso Tricks:
Generate Intel Hex, Binary, and Adding
Checksum
3

5

4

6

18

1. Select ‘C/C++ Build’
2. Select ‘Settings’
3. Select ‘Build Steps’
4. The ‘Post-build steps’ are extra steps that will be done after the project is compiled.
Change this value to generate Intel Hex, Binary, and / or adding checksum into binary
file

18
LPCXpresso Tricks:
Generate Intel Hex, Binary, and Adding
Checksum
To generate Intel HEX file:
– arm-none-eabi-size ${BuildArtifactFileName}; arm-none-
eabi-objcopy -O ihex ${BuildArtifactFileName} $
{BuildArtifactFileBaseName}.hex ;
To generate plain binary file:
– arm-none-eabi-size ${BuildArtifactFileName}; arm-none-
eabi-objcopy -O binary ${BuildArtifactFileName} $
{BuildArtifactFileBaseName}.bin ;
To generate checksum-ed binary file*:
– arm-none-eabi-size ${BuildArtifactFileName}; arm-none-
eabi-objcopy -O binary ${BuildArtifactFileName} $
{BuildArtifactFileBaseName}.bin ; checksum -p $
{TargetChip} -d ${BuildArtifactFileBaseName}.bin;

– Checksum is needed for to indicate valid user code.
19

Checksum is needed for to indicate valid user code. Usually it is inserted by FlashMagic if
the firmware is downloaded through ISP. For firmware that is programmed through USB
ISP, the checksum needs to be added into the binary file first.

19
LPCXpresso Tricks:
View Disassembled Code

1

2

3

20

1. After the program compiled. Right click into its binary result (*.axf)
2. Select ‘Binary Utilities’
3. Select ‘Disassemble’

20
Debugging Blinky

21

21
Debugging Blinky

1

3

2

4 OR

22

1. First compile the Blinky. Right click the ‘Blinky’ project on ‘Project Explorer’ view
2. Select ‘Build Project’ and let the project compiled
3. Make sure that the project compiled successfully. You will see the size of the
compiled firmware after it is built.
4. Start the debugging session using the debug icon on toolbar or ‘Debug <Project
Name>’ on Quickstart Pane.

22
Debugging Blinky

1
2

3

4

23

The ‘Debug’ panel shows important information regarding the debugged program
• Call stack: shows the order of function calling until it reach current position. It shows
function name, source file and line no, and function location in memory
• The buttons to control the debugging (from left to right): Reset, Run, Suspend (not
available until the firmware is run), Stop (exit debugging mode), Disconnect (not
available in LPCXpresso), Step into, Step over, Step return, Drop to frame,
Instruction Stepping Mode, Use Step Filters
• The arrows shows current PC location. The dot shows breakpoint position
• The ‘Instruction Stepping Mode’ can be used to debug the assembly code.

23
Debugging Blinky

OR

1
2

3

24

The local variables (and function parameters) will be displayed in ‘Variables’ view, or,
alternatively, once the program is paused, you can move your cursor into the variable
name and getting it’s value.

If you want to view variable, you can use ‘Watch Expression’ feature. To use it:
• Select the variable name and right click. Select ‘Add Watch Expression…’
• Make sure the variable name is correct and press ‘OK’.
• The variable value can be viewed from ‘Expressions’ view.

24
Debugging Blinky

1
2

3

25

1. The core registers can be viewed from ‘Core Register’ view
2. The peripheral registers, such as Timer0, can be viewed from ‘Peripherals’ view.
3. When one of the peripheral is ticked at ‘Peripherals’ view, the ‘Memory’ view will be
shown along with the peripheral registers values

25
26

26