Monday, 20 August 2012

Week 4

Title of Activity
-Debugging a project.


Objective
-To gives an introduction to how to debug a project. The guidelines assume that you have already created and built a project as described in Getting started: New project.

Content/Procedure
-Prior to starting debugging, a proper debugger must have been selected. As mentioned the AVR Simulator will be used for this example.
-The currently selected device and debugger is displayed in the Device and Debugger tool bar. If no debugger is selected, the Current Tool button will say No Tool as shown here.
-To select a debugger, simply click on the Current Tool button. This opens the debugger selection and configuration in the project properties. The debugger selection and configuration can also be opened via the project Properties menu item found at the bottom of the Project menu. You can also open the project properties by right-clicking on the project node in the Solution Explorer window.
-Select a debugger.
  1. Open the project propeties dialog from the Project menu.
  2. In the Tool section of the propeties, select the AVR Simulator .
  3. Click OK
-There are several ways to start a debug session.
-The Alt+F5 key combination or the Start Debugging and Break menu item builds the project and launches the debugging session. On encountering the main() function the execution is suspended . The same is achieved using the F10 key or the Step Over menu item. The project is not built if it is up to date.
-The F5 key or Continue menu entry builds the project and upon a succesful build launches the debugging session using the selected debugger. This shortcut does not suspend execution until a user breakpoint is hit.









-The Start Without Debugging menu item loads the application into the target device but does not start a debugging session. This command is used as an alternative to the stand-alone Programming Dialog described in later sections. Note that Start Without Debugging uses the projects debug configuration and not the settings specified in the stand-alone Programming Dialog.
-Start debugging.
  1. In the Debug menu, select Start Debugging and Break.
  2. AVR Studio will compile the project, upload the application to the program memory of the AVR Simulator and run to the start of the main() function. AVR Studio displays the text "Debugging" in the title line, indicating that a debugging session is active.
-AVR Studio allows you to control the execution of the target through a large number of commands. These commands are available on the Debug menu or through keyboard shortcuts.
-Resume and suspend execution.
  1. In the Debug menu, select Continue. The AVR Simulator will resume execution, indicated by the text "Running" in the title line of AVR Studio.
  2. In the Debug menu, select Break All. AVR Studio suspends execution. The yellow arrow marks the code line that will be executed when execution is resumed the next time. 
-Breakpoints provides another means of controlling program execution. Once a breakpoint in your code is "hit" by the debugger, execution is suspended.
-A breakpoint can be placed in the source code by clicking in the gutter area next to the source line where you want program execution to be suspended. Alternatively by selecting Toggle Breakpoint in the Debug menu, or simply by pressing F9.
-A red circle will appear in the gutter area.
-Place a breakpoint and run.
  1. Position the text marker on a line in the application and press F9.
  2. Press F5 to resume execution. AVR Studio will execute code until the breakpoint is hit and then suspend execution.
-AVR Studio allows you to observe the current state of the debugged Device through a number of debugger windows. Examples of debugger windows are the memory views, the watch view and the IO view.
-The debugger windows can be accessed on the Debug -> Windows menu or by using specific keyboard shortcuts. Most of the windows will only contain useful information when execution is stopped.
-Open the memory view
  1. Make sure execution is halted (the title bar of AVR Studio should say "Debugging")
  2. Navigate to Debug -> Windows -> Memory and select Memory 1. AVR Studio will open the memory window.
  3. Select "data INTERNAL_SRAM" in the pull-down menu labeled "Memory" over the memory content. This displays the internal SRAM of the selected device.
-To end the debugging session and go back to code editing, select Shift + F5 or select Stop Debugging from the Debug menu.

Result/Analysis
 -This is the step how to debug the program in Atmel Atmega644.
 -Also it more friendly user and easy to understand.

Conclusions
 As a conclusions, the introduction to debugging code projects in AVR Studio. All aspects of debugging are described more in detail in the Debugging section in the AVR Studio

No comments:

Post a Comment