LPCXpresso Hands On

Preview:

DESCRIPTION

NXP LPCXpresso lab hands-on

Citation preview

LPCXPRESSO HANDS ONBy Daniel Widyanto

September 2010

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

3

LPCXpresso Introduction

4

LPCXpresso Introduction

(* )

Evaluation Product Development

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

6

LPCXpresso Layout

7

LPCXpresso Layout1

2

3

8

LPCXpresso Layout

9

LPCXpresso Projects:

Importing Project

10

Importing Project

1

2

3

11

LPCXpresso Projects:

Creating New Project

12

Creating New Project

1

2

13

Creating New Project

3

4

14

LPCXpresso Projects:

Exporting Project

15

Exporting Project

1

2

3

16

LPCXpresso Tricks

17

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

1

2

18

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

3

4

5

6

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.

20

LPCXpresso Tricks:View Disassembled Code

1

2

3

21

Debugging Blinky

22

Debugging Blinky

1

2

3

OR4

23

Debugging Blinky

12

3

4

24

Debugging Blinky

1

3

2

OR

25

Debugging Blinky

1

2

3

26

1

LPCXPRESSO HANDS ONBy Daniel Widyanto

September 2010

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

3

3

LPCXpresso Introduction

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

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)

6

6

LPCXpresso Layout

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

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

9

9

LPCXpresso Projects:

Importing Project

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.

11

11

LPCXpresso Projects:

Creating New Project

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’

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’

14

14

LPCXpresso Projects:

Exporting Project

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.

16

16

LPCXpresso Tricks

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

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

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.

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’

21

21

Debugging Blinky

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.

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.

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.

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

26

26

Recommended