0% found this document useful (0 votes)
3 views

Labsheet6

This document is a lab sheet for a Microcontroller Lab course, specifically focusing on the Keil uVision IDE. It includes prelab exercises, step-by-step instructions for creating and debugging a project, and exercises for executing C and ARM assembly code. The lab aims to introduce students to embedded programming using C and ARM assembly language within the Keil IDE environment.

Uploaded by

am.en.u4eac22015
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Labsheet6

This document is a lab sheet for a Microcontroller Lab course, specifically focusing on the Keil uVision IDE. It includes prelab exercises, step-by-step instructions for creating and debugging a project, and exercises for executing C and ARM assembly code. The lab aims to introduce students to embedded programming using C and ARM assembly language within the Keil IDE environment.

Uploaded by

am.en.u4eac22015
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

19EAC285 Micro-Controller Lab

Lab sheet 6: Introduction to Keil uVision IDE

Subject: Microcontroller Lab Register Number:


Sub Code: 19EAC285 Name:
Experiment No. : 5 Date:
Course Outcome: CO6

Prelab Exercise:

1. What is a Microcontroller?

2. How is a microcontroller different from a microprocessor?

3. What is an Embedded System? Give some real-life examples.

1
19EAC285: Microcontroller Lab

4. What is an IDE? What are the commonly used IDEs for embedded systems development?

Keil IDE: Keil Electronics, provides an Integrated Development Environment called Keil µVision
(pronounced Micro-Vision) that integrates a project manager, editor, compiler, debugger, and simulator in a
single powerful environment; it provides a high efficiency and clear graphic user interface for embedded
software development.

I. Create your first Project: The objective of this


lab sheet is to give you an introduction to the world of
embedded programming using C and ARM assembly
language; here we learn how to use the ARM Keil
uVision IDE to create projects, build and debug them.
Step1: Open the Keil IDE by clicking on its icon on the
desktop.

Step2: Choose a new uVision Project from the Project


menu

Step3: Create a new folder and name it Amrita; type the


name MyProject for the project and click Save.

Step 4: In the Database tree as shown below, choose the vendor and then the chip you want to use and click OK.
If want to use LPC2148, click on the NXP then on the LPC2148, and press OK. (Or in the search box, type
LPC2148 directly and click OK)

2
19EAC285 Micro-Controller Lab

Step 5: A message window will appear and


ask you whether to add the Startup.s file to
the project or not; as we are going to start
with C code, click on the ‘Yes’ button to
add the startup file. Note that if you want to
write an Assembly program then your
answer should be ‘No’ (skip adding
Startup.s).

Step6: Create a new file by choosing New


from the File menu; or you may press
Ctrl+N, as well.

Step 7: Type your first C code in the work space


provided as shown in the following figure

Note that in the text editor window, keywords appear in a different colour; it is to differentiate
keywords from variables, constants, and others,

Step 8: Once the coding is


completed, press the save icon on
the file menu (or press Ctrl+S ).
Name the file as FirstFile.c and
save it as a C file in your personal
folder Amrita.
Step9: Add your FirstFile.c to the
project. To do so: Expand Target1
on the left side panel; Right-click
on the Source Group1 and choose
Add Existing Files to source
Group; then browse the directory
Amrita and choose desired file:
FirstFile.c. Finally, click on the
Add button and Close.

3
19EAC285: Microcontroller Lab

You should make sure that your file is added under


the project by expanding the Source Group shown
under Target (Note that firstfile. c is added under
Source Group 1in the left panel)

II. Building the Project: To build your


code, click on the Build icon or choose
build target from the Project menu
(Project→Build Target). If the program is
built successfully a build output window
appears with 0 Error(s)and 0 Warning(s) as
shown in the following figure. If the build is unsuccessful (i,e, if the build output window is provided with any error –
syntax error), you have to re-edit the source code and build it again until the build becomes successful.

4
19EAC285 Micro-Controller Lab

III. Debugging the Project: Now you need to


use a debugger to see what is happening inside
your program. To start debugging click on the
Start/Stop Debug Session icon or choose
Start/Stop Debug Session from the Debug
menu (or use Ctrl+F5).

When you select Start Debug Session, a


warning that this is an evaluation version
shows up; proceed with OK. Then, a new
window with several different supporting
panels appears where you can see the
simulation of the program. The left-hand side
panel is called the Register window.

III. Running the Project: To run your


project, select Debug- > Run, or click the Run
button on the toolbar; otherwise you may
press the F5 key to run.
The program runs until the simulator encounters a breakpoint. To stop running the project, again select Debug
-> Start/Stop Debug Session, or else click the Stop button on the toolbar. To trace your program you are provided with
the Step Over button (or click on Step Over from the Debug menu); using this tool one may execute his code line by line
(one instruction after another); during the trace, you may verify or modify register content.

To exit from the debug/run mode


press Start/Stop Debug Session.
again

Debugging windows: There are


some special windows provided by
the Keil IDE, to help you to analyze
the code and result through the
Registers, Stack, Memory, and
Ports.
Disassembly window: In the following figure, the disassembly window is walled in green which shows assembly
instructions equivalent to your C code. Let’s go through the assembly code line by line; in fact, by reading an assembly
code, one can realize what the processor is doing exactly.

Register Window: The left most panel (in the following figure, it is walled in blue) is called the register window It
shows 16 general-purpose registers along with the Current Program Status Register (CPSR) and SPSR; this window
allows you to modify the contents. A register can hold a 32-bit signed, unsigned integer or a memory pointer. All C
variables map

5
19EAC285: Microcontroller Lab

onto the registers and large data structures like arrays


will be in a memory. Register Window is a very
handy tool for debugging. Go through the required
registers and verify their contents.

Watch Window: Go through View-> Watch Windows-> Watch-1; this window allows you to view or monitor the
values of the variables or registers that are used in the program during run time (while the program is running); also
you may modify these values without disturbing or terminating the execution. To view the value of any variable the
variable should be added through the <Enter expression> field of the watch window.

Exercise1: Execute the following C-code in KEIL IDE to find the biggest among two numbers. View the change in the
registers in the register window and also the variables in the watch window.

6
19EAC285 Micro-Controller Lab

Exercise 2: Execute the following ARM Assembly code using Keil IDE; while typing the code proper indentation must
be provided as shown in the figure.
(Note: Start a new project, do not add Startup.s file, Save the file with.asm extension)

7
19EAC285: Microcontroller Lab

Signature of the faculty with date: ………………………………

You might also like