52
LPCXPRESSO HANDS ON By Daniel Widyanto September 2010

LPCXpresso Hands On

Embed Size (px)

DESCRIPTION

NXP LPCXpresso lab hands-on

Citation preview

Page 1: LPCXpresso Hands On

LPCXPRESSO HANDS ONBy Daniel Widyanto

September 2010

Page 2: LPCXpresso Hands On

2

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

Page 3: LPCXpresso Hands On

3

LPCXpresso Introduction

Page 4: LPCXpresso Hands On

4

LPCXpresso Introduction

(* )

Evaluation Product Development

Page 5: LPCXpresso Hands On

5

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

Page 6: LPCXpresso Hands On

6

LPCXpresso Layout

Page 7: LPCXpresso Hands On

7

LPCXpresso Layout1

2

3

Page 8: LPCXpresso Hands On

8

LPCXpresso Layout

Page 9: LPCXpresso Hands On

9

LPCXpresso Projects:

Importing Project

Page 10: LPCXpresso Hands On

10

Importing Project

1

2

3

Page 11: LPCXpresso Hands On

11

LPCXpresso Projects:

Creating New Project

Page 12: LPCXpresso Hands On

12

Creating New Project

1

2

Page 13: LPCXpresso Hands On

13

Creating New Project

3

4

Page 14: LPCXpresso Hands On

14

LPCXpresso Projects:

Exporting Project

Page 15: LPCXpresso Hands On

15

Exporting Project

1

2

3

Page 16: LPCXpresso Hands On

16

LPCXpresso Tricks

Page 17: LPCXpresso Hands On

17

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

1

2

Page 18: LPCXpresso Hands On

18

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

3

4

5

6

Page 19: LPCXpresso Hands On

19

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.

Page 20: LPCXpresso Hands On

20

LPCXpresso Tricks:View Disassembled Code

1

2

3

Page 21: LPCXpresso Hands On

21

Debugging Blinky

Page 22: LPCXpresso Hands On

22

Debugging Blinky

1

2

3

OR4

Page 23: LPCXpresso Hands On

23

Debugging Blinky

12

3

4

Page 24: LPCXpresso Hands On

24

Debugging Blinky

1

3

2

OR

Page 25: LPCXpresso Hands On

25

Debugging Blinky

1

2

3

Page 26: LPCXpresso Hands On

26

Page 27: LPCXpresso Hands On

1

LPCXPRESSO HANDS ONBy Daniel Widyanto

September 2010

Page 28: LPCXpresso Hands On

2

2

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

Page 29: LPCXpresso Hands On

3

3

LPCXpresso Introduction

Page 30: LPCXpresso Hands On

4

4

LPCXpresso Introduction

(* )

Evaluation Product Development

• 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

Page 31: LPCXpresso Hands On

5

5

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

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)

Page 32: LPCXpresso Hands On

6

6

LPCXpresso Layout

Page 33: LPCXpresso Hands On

7

7

LPCXpresso Layout1

2

3

The LPCXpresso working area is divided into three major blocks:1. Menu and Toolbar2. Workspace area3. 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

Page 34: LPCXpresso Hands On

8

8

LPCXpresso Layout

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

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

Page 35: LPCXpresso Hands On

9

9

LPCXpresso Projects:

Importing Project

Page 36: LPCXpresso Hands On

10

10

Importing Project

1

2

3

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 package1. 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.

Page 37: LPCXpresso Hands On

11

11

LPCXpresso Projects:

Creating New Project

Page 38: LPCXpresso Hands On

12

12

Creating New Project

1

2

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

Page 39: LPCXpresso Hands On

13

13

Creating New Project

3

4

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’

Page 40: LPCXpresso Hands On

14

14

LPCXpresso Projects:

Exporting Project

Page 41: LPCXpresso Hands On

15

15

Exporting Project

1

2

3

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.

Page 42: LPCXpresso Hands On

16

16

LPCXpresso Tricks

Page 43: LPCXpresso Hands On

17

17

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

1

2

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

Page 44: LPCXpresso Hands On

18

18

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

3

4

5

6

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

Page 45: LPCXpresso Hands On

19

19

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.

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.

Page 46: LPCXpresso Hands On

20

20

LPCXpresso Tricks:View Disassembled Code

1

2

3

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

Page 47: LPCXpresso Hands On

21

21

Debugging Blinky

Page 48: LPCXpresso Hands On

22

22

Debugging Blinky

1

2

3

OR4

1. First compile the Blinky. Right click the ‘Blinky’ project on ‘Project Explorer’ view2. Select ‘Build Project’ and let the project compiled3. 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.

Page 49: LPCXpresso Hands On

23

23

Debugging Blinky

12

3

4

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.

Page 50: LPCXpresso Hands On

24

24

Debugging Blinky

1

3

2

OR

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.

Page 51: LPCXpresso Hands On

25

25

Debugging Blinky

1

2

3

1. The core registers can be viewed from ‘Core Register’ view2. 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

Page 52: LPCXpresso Hands On

26

26