Summary
When debugging an MPLAB® X project you may find it useful to view the variables and PIC® Special Function Registers (SFRs). Global Variables and SFRs have permanent and fixed memory devices. All programs can access these data elements at any time. This page shows how to access global variables and SFRs. At the end of this page is a link to a tutorial demonstrating how to access Watches.
What is the Watches Window
The Watches window is the MPLAB X utility that allows you to observe and modify Global Variables and SFRs. This window is part of the standard MPLAB X debug tools and can be used anytime during an active debug session. The Variables window operates with all MPLAB X support debug tools (software simulator, ICD 4, REAL ICE™, and PICKit™ 4). Many third-party debug tools and simulators also allow the Watches window to operate.
How to Open the Watches Window
- Make sure you are in a debug session.
- Select Windows > Debugging > Watches (or ATL+SHIFT+2).
The Watches window will open up in the Output window section. (Usually the lower right-hand side.)
Any value left in the Watches window from a previous debug session will remain in the Watches window when it is reopened. This avoids the necessity of reloading. To erase the Watches from a previous session, right-click in the Watches window, then select Delete All.
Adding Items to the Watches Window
To add an element to the list of items being watched, first right-click in the open Watches window. Then select New Watch from the drop-down menu.
A pop-up menu will display and allow you to select either a Global Variable or a SFR to add to the Watch. Select the either SFR or Global Symbol. Once selected, the box will fill with a list of all the Global Symbols or SFRs. Select the individual item you wish to add, then select OK.
Repeat these steps until you have added all the desired Watches.
Modifying the Display Properties
Right-click on the menu bar of the Watches window to bring up the Display Visible Options window. This will allow you to add and remove display columns. You can change the width of each column or sort the table by the elements in each.
Left-click on either the Type or Name heading to sort the entries.
Saving Watches to a file
You have the option to save the current list of items in the Watches window to a file. You can also reload the list of watches from a saved file. Two icons on the left-hand side of the Watches window control these functions.