Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

The insider's guide to the Philips ARM7-based microcontrollers (T. Martin, 2005)

.pdf
Скачиваний:
150
Добавлен:
12.08.2013
Размер:
6.1 Mб
Скачать

Introduction to the LPC2000

5 – Tutorial With Keil Tools

 

 

In the debug tab select make sure the use simulator radio button is checked along with the “Load application at startup” and “Go till main”.

Select OK to complete the target options.

In the project browser expand the ‘target1’ root node to show the source group 1 folder.

130

Introduction to the LPC2000

5 – Tutorial With Keil Tools

 

 

Highlight the ‘source group 1’ folder, open the local menu with a right click and select ‘Add files to source group source group1’’.

In the ‘Add files to group’ dialog add the file blinky.c and serial.c.

Change the ‘Type of file’ filter to ASM and add the file startup.s

These are all the source files necessary for the project so select “Close” . Notes:

(i)You can view the source code contained in a file by double clicking on the file name in the project browser window.

(ii)The “manage components/project components” option also allows you to customise your project by adding extra source groups and different build options such as build for RAM debugging or Flash, debug in the simulator or with the JTAG.

Build the code by selecting the Project\build target menu or the F7 key. Build Icons are also available on the toolbar.

131

Introduction to the LPC2000

5 – Tutorial With Keil Tools

 

 

For the rest of the tutorial, the projects will be defined but relevant bits of code will be missing. A complete copy of the exercise can be found in the solution directory. All the example code is included on your CD.

132

Introduction to the LPC2000

5 – Tutorial With Keil Tools

 

 

Using The Debugger

Launch the debugger by selecting the ‘debugger\start/stop debugger session menu or the button on the toolbar.

The code will be loaded into the simulator and executed from the reset vector until it reaches main().

The project browser is replaced by a register window that allows you to view the contents of the CPU registers. Here you can:

-View the registers in each of the different operating modes

-Open the SPSR and CPSR registers to view the flags

-View the internal mode to the simulated cycle count and timestamp

-Change the contents of a register by triple clicking on its value and then entering a new value.

133

Introduction to the LPC2000

5 – Tutorial With Keil Tools

 

 

From main(), single step the code:

Use F11 to step a line of code

Use F10 to block step lines of code and functions

Use F5 to run the code at full speed

Use Esc to halt the code

Note: For the single step commands to work, a source code window must be the active window

To set a breakpoint:

Select a line of code, right click for the local menu and select “insert/remove breakpoint”. Now press F5 to run to the breakpoint.

Run to a point in the code:

This is a quick way of getting to an arbitrary pointing your code.

Select a line of code, open the local menu, “select run to cursor”. This will execute code until this line is reached. You can also select “Set program counter”. This forces the PC to the current position without running any code.

134

Introduction to the LPC2000

5 – Tutorial With Keil Tools

 

 

Select view/disassembly to see the underlying assembler code:

Examine program variables:

In the C code window place the cursor on the “counter” variable. Open the local window and select “Add counter to watch window” in the sub menu select #1

In the “Watch and call stack window”, select the Watch #1 tab to view the contents of counter

135

Introduction to the LPC2000

5 – Tutorial With Keil Tools

 

 

Examine memory locations:

Open the memory window with “view\memory window”

Set the start of the memory window to 0x40000060, the address of the counter variable.

View the device peripherals:

Open some of the windows under the Peripherals menu.

136

Introduction to the LPC2000

5 – Tutorial With Keil Tools

 

 

The debugger has many mode functions but the above debugging tools will allow you to run the course exercises. The simulator can also be replaced by a JTAG debugger and the same front end can be used to debug real hardware.

137

Introduction to the LPC2000

5 – Tutorial With Keil Tools

 

 

Using The ULINK Hardware Debugger

The JTAG debugger included with the starter kit is the Keil ULINK. This connects to the JTAG port on MCB2100 (P5) and then connects to the PC via USB. To switch from using the simulator to using the ULINK, follow the steps below.

Setting up the ULINK JTAG hardware debugger:

Connect the ULINK to the MCB2100 as shown below and plug the USB connection into the PC. Power should also be connected to the MCB2100 (6.5V).

Configure UVISION to use the ULINK in place of the simulator:

First open the utilities menu in the “Options for target” dialogue . Select the “use target device for Flash programming” radio button and select the ULINK ARM7 debugger from the drop down menu. Also tick the update target before debugging box

138

Introduction to the LPC2000

5 – Tutorial With Keil Tools

 

 

Configure the flash algorithm:

Next click the setting button. Set the start address for the RAM at 0x40000000 with a size of 0x400. Click the add button and select the flash algorithm for the device you are using then click OK to quit.

Switch from the simulator to the JTAG debugger:

Again open the options for target dialogue and select the debugger menu. On the right hand side of the menu select the ULINK ARM7 Debugger from the dropdown menu and tick the Use radio button.

UVISION is now ready to use the ULINK JTAG in place of the simulator.

If you are in the JTAG debugger or simulator you must halt any running code and quit the debugger before you can rebuild the code or quit the project.

139