0% found this document useful (0 votes)
276 views11 pages

Lab 1 - Getting Started With Keil MDK - BENC2423

Uploaded by

01 PrOdUcTiOn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
276 views11 pages

Lab 1 - Getting Started With Keil MDK - BENC2423

Uploaded by

01 PrOdUcTiOn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Getting Started with Keil® MDK

FAKULTI KEJURUTERAAN ELEKTRONIK DAN


KEJURUTERAAN KOMPUTER

BENG 2431

ELECTRONIC ENGINEERING LABORATORY 2

GETTING STARTED WITH KEIL® MDK

Computer Engineering Department, FKEKK


(2022)

1/11
Getting Started with Keil® MDK

1.0 Objectives

1. To install the Keil® MDK for ARM Cortex-M3 development tool


2. To gain an understanding of the standard development tools used in
programming ARM Cortex-M3 microcontroller

2.0 Equipment Required

1. Personal computer running Microsoft Windows® XP SP2 (and above) with


minimum of 512MB RAM running Keil µVision 5.
2. mbed NXP LPC1768 microcontroller board

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

The MDK-ARM is a complete software development environment for Cortex™-M, Cortex-


R4, ARM7™ and ARM9™ processor-based devices. MDK-ARM is specifically designed
for microcontroller applications, it is easy to learn and use, yet powerful enough for the
most demanding embedded applications. Keil MDK includes IDE, C/C++ compiler,
debugger, Software Pack management, and CMSIS. MDK Version 5 Software Packs add
device support and software components that are managed using the new Run-Time
Environment (RTE). Real-time debug and trace capabilities are improved with RTOS stack
watermarking and Event Viewer.

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.

2. Install Keil’s Microcontroller Development Kit for ARM by double clicking on


mdk517.exe. The dialog box shown below would appear

3. Follow the instruction to install MDK-ARM v5.17. You need not install the U-
Link Me Driver when prompted after installation completes.

4. After installation complete, close all windows. Double-click on


Keil.LPC1700_DFP.2.2.0 pack to install the files need for handling the NXP
LPC1700 series of microcontrollers. (Get the pack files in our ULearn page).

Acknowledgement: This labsheet has been prepared with the assistance of Dr. Royan Ong from ProvenPac
3/11
Getting Started with Keil® MDK

5.2 Create New Project

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.

3. Click OK when done, and OK in the Manage Run-Time Environment


window.

4. The IDE should be similar to that 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

5.3 Add New Assembly File

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.

2. Type the listing shown below into the source file.

AREA MYCODE, CODE, READONLY ; code area (segment)


ENTRY ; start of area MYCODE

EXPORT SystemInit ; export SystemInit symbol


SystemInit ; SystemInit routine

EXPORT __main ; export __main symbol


__main ; __main routine
MOV R2, #0xC020 ; move 0xC020 into R2
MOVT R2, #0x2009 ; assign 0x2009C020 to R2

MOV R4, #0x0 ; place 0x0 into R4


MOVT R4, #0x00B4 ; place 0x00B40000 into R4
STR R4, [R2] ; set 0x2009C020 to 0x00B4000

; Load data memory location 0x2009C038 with the value of 0x00040000

ALIGN ; ensure the area is memory aligned


END ; end of assembly file

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

5.4 Build Project

1. Select Project → Build target (or press F7) to compile the code. The Build
Output window should show the following.

*** Using Compiler 'V5.06 update 1 (build 61)', folder: 'C:\Keil\ARM\ARMCC\bin'


Build target 'Target 1'
After Build - User command #1: C:\Keil\ARM\ARMCC\bin\fromelf.exe --bin --
output=.\Objects\LO2.bin .\Objects\LO2.axf
".\Objects\LO2.axf" - 0 Error(s), 0 Warning(s).
Build Time Elapsed: 00:00:00

2. If the build process failed, fix the Error(s) and try again.

5.5 Simulate Project

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.

5. µVision integrated simulator emulates most of the peripherals of the NXP


LPC1768, which can be seen by selecting Peripherals from the main menu.
Open GPIO Fast Interface → Port 1 to view the status of this peripherals, as
shown 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)..

9. Select Debug → Reset CPU to reset 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

5.6 Loading the Executable File to the Board

1. Right-click on Target 1 and select Options for Target ‘Target 1’ to bring up


the dialog box, as shown below. Check Run #1 of the After Build/Rebuild
section in the User tab. Enter

C:\Keil\ARM\ARMCC\bin\fromelf.exe --bin --output=.\objects\L01.bin .\objects\L01.axf

in the User Command section as shown below. Click OK when done.

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

In your technical report;

1. Show the flowchart of the whole process done in the Procedures.


2. Describe what you had understood from this session.

Acknowledgement: This labsheet has been prepared with the assistance of Dr. Royan Ong from ProvenPac

11/11

You might also like