How to debug in Keil Microvision

In this article we will take a look at Debugging feature of Keil uVision. In Previous Article we had seen how to create project, hex file and building Project. Once you build your project and if you see 0 errors and 0 warnings you are half way through your project.

Now what is debugging?

Debugging is to identify and fix bugs in your project e.g. logical or synchronization problems in the code, or a design error in the hardware.First go at Debug Tab on Menu bar, click on Start/Stop Debug.

[You can also start debugging by clicking on “d” at file tool bar, or press Ctrl + F5]

debugging in Keil Microvision

Now here comes important function called Breakpoint in Debugging.


Breakpoints are trigger points in your program that halt execution or execute a debugger function.

How to Insert/Remove Breakpoint?

  • Click on line you want to insert/remove breakpoint
  • Go to Debug Tab on Menu bar
  • Select Insert/remove Breakpoint

You can also put breakpoint from Toolbar by clicking on Breakpoint icon.Easiest way to Inserting or removing breakpoint is to click before Line number.After inserting breakpoint you will see Red Dot in front of line number.

Inserting breakpoints in Keil microvision

What is importance of Breakpoint?

You can check execution of your program on particular line, and can check if the output on that part is as expected or not.When your program is too long, it is difficult to check execution and finding logic errors. So by putting breakpoints you can divide program into several parts and can check each part one by one.

What can you do by breakpoint?

By inserting breakpoint you can

  • Check execution line by line
  • Executing predefined instruction every time breakpoint comes like counting of execution or checking any register value etc.

Running, Stopping and Resetting your Program

  • Go to Debug and click on Run.
  • Shortcut for Run is Function key F5.
  • You can also find option above run in debug tab of Reset CPU, by which program will be reset and execution will start from first line.
  • Stop will stop the execution of program.

Run (F5) a program in Keil micro vision

Now when you insert breakpoint(s) you have some function by which you can execute your program as per your wish.

STEP [F11]

Executing next statement


Don’t Execute current line and go on next line.

STEP OUT [Ctrl + F11]

Stepping out of execution of whole function of that line. Example. If you are in function of delay and you press step out it step out of that function and executing next statement.

Run to The Cursor Line[Ctrl + F10]

Execute the cursor line. It will take execution of program to the cursor line.

Show Next Statement

Go to line of Program Counter. Yellow arrow in front of line number is position of program counter.

Next time we will take a look at more use of Breakpoints and other windows in Debugging. If you have any questions, you are most welcome to comment below.Once you run your program, you can check values of your device register, timer, ADC, PWM all under Peripheral tab in menu bar which will be covered in article which will be on Simulation.

Simulation Keil Microvision