Lab 1 - Getting Started With Keil MDK - BENC2423
Lab 1 - Getting Started With Keil MDK - BENC2423
BENG 2431
1/11
Getting Started with Keil® MDK
1.0 Objectives
3.0 Safety
1. Ensure hands are dry when using the equipments or touching the switches.
2. Do not use plugs with cracks, signs of overheating (e.g. discoloration,
charring or deformation) or loosen parts.
3. Stop using the equipments if abnormal operating conditions occur, such as
being too noisy or having signs of overheating.
4. Keep all equipments in an organized manner, where they are easy to reach
without bending or stretching.
4.0 Theory
Acknowledgement: This labsheet has been prepared with the assistance of Dr. Royan Ong from ProvenPac
2/11
Getting Started with Keil® MDK
5.0 Procedures
5.1 Installation
1. Make sure that the Keil μVision software is already installed in your
workstation. If not, go to the webpage (https://www2.keil.com/mdk5/) and
click the ‘Download MDK’ button to get the installation file.
3. Follow the instruction to install MDK-ARM v5.17. You need not install the U-
Link Me Driver when prompted after installation completes.
Acknowledgement: This labsheet has been prepared with the assistance of Dr. Royan Ong from ProvenPac
3/11
Getting Started with Keil® MDK
1. Start Keil µVision 5 and select Project → New µVision Project. Create a new
project and name the project L01. It is strongly advised that each project
should be stored in its own folder. Click Save when done.
2. Expand the NXP, LPC1700 series and LPC176x tabs and select LPC1768
as the device in the Select Device for Target ‘Target 1…’ dialog box, as
shown below.
Acknowledgement: This labsheet has been prepared with the assistance of Dr. Royan Ong from ProvenPac
4/11
Getting Started with Keil® MDK
5. Expand Target 1 and right-click Source Group 1. Select Add Existing Files to
Group 'Source Group 1'… from the context menu. If you have installed the
Keil compiler at its default location (C:\Keil), navigate to
C:\Keil\ARM\Pack\Keil\LPC1700_DFP\2.2.0\Device\Source\ARM and select
startup_LPC17xx.s, as shown below. Modify the path if you have installed
the Keil compiler at other locations. This would insert the startup assembly
script for the target device into the project. (If you can’t get the startup file,
please get it in our ULearn page).
Acknowledgement: This labsheet has been prepared with the assistance of Dr. Royan Ong from ProvenPac
5/11
Getting Started with Keil® MDK
1. Right-click Source Group 1. Select Add New Item to Group 'Source Group
1'… from the context menu. Select ASM File (.s) and enter a file name. Click
Add.
3. Modify the code based on the comment given after the STR instruction.
Acknowledgement: This labsheet has been prepared with the assistance of Dr. Royan Ong from ProvenPac
6/11
Getting Started with Keil® MDK
1. Select Project → Build target (or press F7) to compile the code. The Build
Output window should show the following.
2. If the build process failed, fix the Error(s) and try again.
1. Right click on Target 1 and select Options for Target ‘Target 1’ to bring up
the dialog box, as shown below. Check Use Simulator in the Debug tab.
Acknowledgement: This labsheet has been prepared with the assistance of Dr. Royan Ong from ProvenPac
7/11
Getting Started with Keil® MDK
2. Ensure that Dialog DLL and Parameter has the values shown above (the
default may be different).
3. Select Debug → Start/Stop Debug Session (or CTRL-F5) and click OK to the
dialog box. The view shown below would appear. Resize/rearrange the
windows to get a clearer view of the source code.
4. To view the memory data, select the Memory 1 tab at the bottom right
window. Enter an address in the Address field followed by pressing Enter.
The Memory window should be as displayed below.
Acknowledgement: This labsheet has been prepared with the assistance of Dr. Royan Ong from ProvenPac
8/11
Getting Started with Keil® MDK
6. To create a breakpoint, click the space on the left and a red circle appears
as shown below.
7. Select Debug → Run (or click the icon or press F5). Execution should
top at line 14. The GPIO Fast Interface window would be as shown below.
8. To stop the simulator, select Debug → Stop (or click the icon to stop the
simulator)..
10. Select Debug → Start/Stop Debug Session to stop the debugger and return
to the code editor.
Acknowledgement: This labsheet has been prepared with the assistance of Dr. Royan Ong from ProvenPac
9/11
Getting Started with Keil® MDK
Note: fromelf.exe would execute after the code is compiled to convert the
.axf format file into a binary (.bin) file. Only the .bin file could be executed by
the mbed NXP LPC1768.
2. Recompile the code and ensure that L01.bin is created in the objects
subfolder of the project.
Acknowledgement: This labsheet has been prepared with the assistance of Dr. Royan Ong from ProvenPac
10/11
Getting Started with Keil® MDK
3. Connect the mbed NXP LPC1768 to the computer with the supplied USB
cable. The mbed would show up as a drive. Launch Windows Explorer and
copy L01.bin to the root of the drive. Press reset and ensure that one of the
four blue LED at the edge of board would be lit.
You can place many .bin files in the root folder of the drive created when
mbed is connected to the computer. Only the newest .bin file would be
executed when reset is pressed.
6.0 Exercise
1. Modify the program so that all FOUR (4) LEDs on the board will turned ON.
Share the following screenshot to show the result in your technical report:
a. Full program code
b. GPIO Fast Interface window
c. Memory window at location 0x2009C038
d. Registers content
2. Show the mbed LPC1768 microcontroller board in your technical report to
demonstrate the final result.
7.0 Discussion
Acknowledgement: This labsheet has been prepared with the assistance of Dr. Royan Ong from ProvenPac
11/11