Keil DebuggingPrograms

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Keil uVision

Debugging Programs

WEL Labs, IITB


2016
Development Tools (Revision)
• Coding – Editor => Entry of code into file(s)
• Translation – Assembler or Compiler
=> Generate machine code from source code
• Execution check – using Debugger to verify
operation of program ( on Simulator )
• Program – Programmer
=> Put machine code in the chip
Single Point Solution – IDE e.g. Keil
Keil uVision IDE …
• Project : A collection of files related to a
particular programming task.
• Build : The process in which only the files
modified since last build are
assembled/compiled for the chosen
microcontroller device.
• Rebuild : The process in which all files are
assembled/compiled irrespective of their
modification state.
• Debug : The process of finding errors
happening during program execution and
removing them.
Simulator and Debugger
• Simulation of microcontroller behavior while
executing the user program
• The Debug mode UI allows the user to perform
the following
1. Observe microprocessor Registers,
Memory, Ports and Peripherals
2. Place breakpoints to stop simulation as
specific instruction or on condition
3. Monitor code under execution
4. Modify data variables
5. Monitor timing of execution
Assuming you have already built
a program and obtained binary
code file for it, We can use the
simulator available with keil for
debugging programs
After a successful build of the
project, following are the resulting
files
1. Binary code is placed in
filename.obj for each source
file in a project.
2. All these obj files are linked
into a single binary named
using the project name
without any extension.
3. If enabled by user
<<filename.hex>> file is
created for the project.
The user can now start the
Debug session to check
execution of the program.
A popup of Evaluation version is presented which shows the
limitation of the mode.
On clicking “OK” the popup closes and the user is presented
with the Debug Mode user interface (UI)
User interface in Debug mode
Disassembly window – shows the
Opcodes for the Program loaded in
the debugger.

User program window – shows the


Register
Assembly or High Level Program
window
loaded in the debugger.

Memory window

Command window
User can execute instructions
in multiple modes :

1. Run (F5) – Continues executing the


program until the next active
breakpoint is reached or till the
program termination.

2. Step (F11)-- Executes a single-step


into a function; Executes the
current instruction line.

3. Step Over (F10) – Executes a single-


step over a function.

4. Run to Cursor Line (Ctrl+F10)


Allows user to place a cursor and
run the program till that line.
Details of Disassembly and Memory window

Disassembly window

Address Instruction mnemonic in assembly language


Opcode

Enter address here Memory window

Data at address 0x0100


Code and Data memory access

d: refers to data memory

c: refers to code segment of the memory


During execution, user can right click on the required
memory location in the memory window to modify RAM
data. Functionality for selecting the number system in
which the memory contents are to be displayed is also
available .
Note: To initialize memory contents on hardware, user has
to add necessary instructions in the program code.
The Registers window
provides access to all the
registers including the flag
register , DPTRs etc.
If some windows are not being displayed
then use the “View” menu to get them on
the window.
To set a breakpoint,
user can click in the
marked area against
the corresponding
line of code
The breakpoint is
shown as a red dot
against the line.

The
breakpoint is
automatically
displayed at the
equivalent
line in the disassembly
window too.
Peripherals menu
Various Peripherals
can be
accessed through the
“Peripherals” menu.

Window
corresponding
to Timer 0
Logic analyzer

To start the logic analyzer click on the


highlighted icon or go to
View > Analysis Window > Logic Analyzer.
Logic Analyzer window

1. Click on Setup

2. The setup window appears.


3. Click on the “New/insert” icon.

4. Type in the pin you want to monitor


then click on Close.
5. After running a simulation, you can pause it and
look at the timing waveforms to debug your code.
Questions ?
Thank you

WEL Labs, IITB


2016

For doubts/errors in this PPT contact :


Suryakant Toraskar e-mail: [email protected] location : WEL5

You might also like