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

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

STEP OVER [F10]

 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

Author

4 Comments

  1. Nimmala Murali

    Thanks for your valuable information.It helped me understand,
    eagerly waiting for next article on debugging.

  2. helloo..
    keil software is very much new to me. i cant get the clear view of debug section. sir plz.. i couldn’t get how to debug the file if there is no breakpoints. generally breakpoints are not essential they depend on user wish and based on application/program… it isn’t it sir?? so please clear my doubt sir..

    • Nilay Banker

      it’s not necessary to insert breakpoints while debugging.

      you start debug and then click on run.
      now you have written your program for some output.
      when you run your program in debug, you check weather you getting desired output or not.
      if you get desire output then your program is correct and no error in it.
      you have done with your debugging.

      if you don’t get right output then you have logical error in program.
      with small program you can easily find error.
      but if your program is very large it is very difficult to find error.

      so by inserting breakpoints you can divide your program into several parts.
      now while executing program,execution will stop at breakpoint,so you can check that execution till this line is right or not.
      so you can one by one check every part to find error and solve it when you find error.
      Finding and solving error is called debugging!!

      you can keep check of register values or variables by different windows in debugging. which will be explained in next article.
      hope you find help from my answer!