You are on page 1of 12

Keil LPC900 Development Studio Tutorial

This tutorial demonstrates the use of the Keil LPC900 Integrated Development
Environment (IDE) in program development and test for the MCB900 microcontroller
board.

The LPC900 IDE contains the following tools: -


• A51 assembler, C51 compiler and linker
• Simulator
• ISP (In-System Programming) interface to allow programming of the MCB900
board
• An In-System Debugger to assist in project debugging.

The MCB900 is a prototype board for the Philips P89LPC935 microcontroller. The board
provides access to all of the microcontroller I/O pins. The Port 2 pins are connected to 8
LED’s. The MCB900 board may be programmed via a serial cable connected to a PC.

This tutorial will develop C code to flash the LED connected to Port 2 pin 0 on and off.
The following steps take place: -
1. Generate a uVision project file
2. Write the C application code and generate the project to product an object file and
a hex file.
3. Use the uVision simulator to simulate the functionality of the code.
4. Program the project hex file onto the MCB900 board and run the code.
5. Use the in-system debugger to test the code on the board.

LPC900 IDE Tutorial 1


Step 1 : Generating a uVision Project

Start the Keil uVison3 application.

Create a new design project. Select New Project from the Project pull-down menu.

LPC900 IDE Tutorial 2


Select the Philips P89LPC935 microcontroller as the target device.

Select Yes when prompted to add the LPC900 start-up code to the project folder.

LPC900 IDE Tutorial 3


This will create a new project called lab1. The project contains a target called ‘Target1’
and a source group folder associated with this target. Currently the source group only
contains theLPC900 startup code.

Now we must create a C file containing our application code and add it to the source
group folder. Create a new file. Save the file as lab1.c.

LPC900 IDE Tutorial 4


Add the lab1.c file to the Source Group 1 folder. Right click on the Source Group 1
folder and select “Add Files to Group”.

Write the C code to flash the LED and then build the project. Use ‘Rebuild all target
files’ from the Project pull-down menu.

LPC900 IDE Tutorial 5


Step 2 :Code Simulation

Before simulating your code ensure that the correct crystal speed has been chosen for
your target microcontroller. The MCB900 microcontroller board uses the on-board
7.373MHz RC oscillator. To check the crystal settings choose Options for Target ‘Target
1’ from the Project pull-down menu. Select the target field and set the crystal (XTAL)
frequency to 7.373 MHz.

LPC900 IDE Tutorial 6


To start a simulation session choose Start/Stop Debug Session from the Debug pull-down
menu.

The uVision project window now contains a number of sub-windows. The project
workspace window shows the current contents of the most important registers. It also
displays the code execution time in seconds. The editor window shows the C code and a
disassembly window showing the assembly code generated during the build process.

During our simulation we want to be able to monitor the status of Port 2 pin 0. We can
view all 8 pins of Port 2 by selecting Port 2 from the I/O Ports pull down menu in the
Peripherals menu. A tick on a pin means that it is at a logic high. A blank on a pin is a
logic low. An alternative method is to add Port 2 or the led0 variable to a watch window.

LPC900 IDE Tutorial 7


We are now ready to simulate the code. The following options are available from the
Debug pull-down menu: -
• Go
• Stop
• Step into
• Step over
• Run till cursor
• Set Breakpoint

LPC900 IDE Tutorial 8


Step 3: Programming the MCB900 Microcontroller Board

We are now ready to program our code into the microcontroller’s on-board flash
memory. Ensure that the MCB900 board is powered up and that there is a serial
connection to the PC.

The programming process transmits a hex file from the PC to the MCB900 micro via an
RS232 interface. We must configure the target option to ensure that a hex file is
generated during the build process. Choose Project, Options for Target ‘Target 1’. Select
the Output tab and tick the ‘Create Hex File’ box. After this is done re-build the project.

To program the board set the board jumper settings as follows :-


Reset Jumper On
Run Jumper Off

Program the board by selecting Download from the Flash pull-down menu.
When programming is complete change the jumper settings as follows to run the
program:-
Reset Jumper Off
Run Jumper On

LPC900 IDE Tutorial 9


Step 4: Using the ISD51 In-System Debugger

The Target Monitor is a program (provided by Keil) that you configure, compile, load,
and run on your target hardware. It communicates (usually via the serial port) with the
µVision3 debugger and allows you download and debug your programs in real time.

ISD51 (In-System Debugger) is a small debug monitor (500-700 bytes) that links with
your 8051 target program. It interfaces to the µVision Debugger using the 8051's on-chip
UART and allows you to view memory, set breakpoints, single-step, and perform
numerous debugging operations.

To use the ISD51 in-system debugger the ISD51.A51 source code must be linked to your
application code. Follow the following steps: -
1. Copy the files ISD51.A51 and ISD51.H from c:\keil\c51\ISD51\examples\Philips
LPC9xx into your project folder.
2. Add the files ISD51.A51 and ISD51.H to the source group of your project.
3. Include the following statement at the top of your C file: -
#include “ISD51.H”
4. Add the following code at the top of your main() function in your C file. This
code will configure the serial port baud rate and interrupt and will initialise the
debugger.

P1M1 = 0;
//Initialise serial port
BRGR0 = 0xF0; /* 9600 baud, 8 bit, no parity, 1 stop bit */
BRGR1 = 0x02;
BRGCON = 0x03;
SCON = 0x52; /* enable serial uart & receiver */
EA = 1; /* Enable global interrupt flag */

//Initialise ISD51
ISDwait();

LPC900 IDE Tutorial 10


After building your project, program the MCB900 board as before (choose Download
from the Flash pull-down menu).

To program the board set the board jumper settings as follows :-


Reset Jumper On
Run Jumper Off

LPC900 IDE Tutorial 11


Set-up the debugger to use the Keil ISD51 In-System Debugger instead of the simulator.
To do this choose Options for Target ‘Target 1’ from the Project pull-down menu. Select
the debug field and configure the debugger as shown below..

You can now simulate your code as before using single step, breakpoints etc. The
difference here is that your code is now running on the target hardware.

LPC900 IDE Tutorial 12

You might also like