Running A Debug Session (rev. 3.00)

NOTE: Microchip updates its tools regularly. This page is an older version that we have preserved for the convenience of those who are supporting existing designs based upon older versions of our tools. Please check http://microchipdeveloper.com/tls0101:run-debug-session for the updated version of this page.

After ensuring the desired debug startup option has been set and ensuring the appropriate programmer/debugger has been chosen, a Debug Session can be started by clicking on the Main_Debug_Project.png Debug Project Icon.

Four things will happen when a debug session has been initiated:

  1. The project will build
  2. MPLAB® X IDE will connect to the selected debug tool and download the built image
  3. The Debug Icons will appear on the Toolbar
  4. The application in the PIC® MCU will run according to the debug startup option
screenshot.png

An illustration of MPLAB X IDE's user interface immediately after a debug session has been started. This example shows the operation when the Debug Startup option is set to MAIN.

When the program being debugged is not running, the location of the Program Counter is shown on the screen with a green line.

Debug Icons

ToolbarDivider.png Debug_Finish_Debugger_Session.png Debug_Pause.png Debug_Reset.gif Debug_Continue.png Debug_Step_Over.png Debug_Step_Into.png Debug_Run_To_Cursor.png Debug_Set_PC_at_Cursor.gif Debug_Focus_Cursor_at_PC.gif ToolbarDivider.png

Step-by-Step Instructions:
Tour of the debug toolbar Icons

When a debug session has been started a new toolbar will appear.
The Debug icon toolbar contains 9 buttons which allow for program control and ease of debugging.

Looking at Global Variables and SFRs

Global Variables (variable with fixed addresses and scope) can most easily be view by the Watches Window. When the Watches Window is opened the user can add a list of variables to "watch". Each time the debug session pauses the program the value of the items being watched is updated. PIC Special Function Registers SFRs work just like Static variables and can be added to any Watches Window

Step-by-Step Instructions:
Setting up the Watches Window

To open the Watches window select Window->Debugging->Watches from the toolbar. The Watches window will appear as a tab in the lower right hand corner ( the Output Window). Right clicking anywhere in the Watches window will allow you to add or delete Watches.

Observing Local Variables

Local Variables (variables who exist only on the stack) can be view by the Variables Window. When the Variables Window is opened the variables who are 'local' to the active function are displayed. The user has the choice of selecting all local variables or just those 'near' the program counter.

Step-by-Step Instructions:
Setting up the Variables Window

To open the Variblees window select Window->Debugging->Variables from the toolbar. Just like the Watches window the Variables Window will appear as a tab in the lower right hand corner ( the Output Window). The three icons on the left hand side of the Variables window allow you to modify the range of the local variables displayed or to add Watches to the Variables window.

Watches can be added to the Variables Window. This allows one window to display Global variables, SFRs, and Local Variables. Some user's find it easier to debug with only one window show data values.

Finishing the Debug Session

When the debugging has been complete and you wish to create an image which can run in the PIC MCU without the need of a programmer/debugger two step are needed. The first step is to end the debug session. Once the debug session has been ended you will need to create the production ready image

To end the debug session click on the "Finish Debug Session" icon Debug_Finish_Debugger_Session.png

Video: Running a Debug Session with MPLAB X IDE

© 2023 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.