Using the Watches Window to Access Global Variables and Registers (SFRs)

Last modified by Microchip on 2024/06/24 06:30

What is the Watches Window

The Watches window is the MPLAB® X Integrated Development Environment (IDE) utility that allows you to observe and modify Global Variables and Special Function Registers (SFRs). The Watches window is part of the standard MPLAB X IDE debug tools and is available during a debug session.

The Watches window operates with all MPLAB development ecosystem supported debug tools, the MPLAB X Simulator and most third-party debug tools.

Opening the Watches Window

Make sure you are in a debug session.

Select Windows > Debugging > Watches (or ATL + SHIFT +2)
Watches opening

The Watches window will open up in the Output window section. (Usually the lower right-hand side.)

Watches after opening

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.

Watches delete all

Back to top

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.

watches new

A pop-up menu will display and allow you to select either a Global Variable or an 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.

watches new SFR

Repeat these steps until you have added all the desired Watches.

watches loaded

Back to top

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.

Watches right click display

Left-click on either the Type or Name heading to sort the entries.

watches sort

Back to top

Saving and Importing Watch Lists

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.

watches save to file

Back to top

Watches In Local Variables View

The Blue Jewel icon ShowWatches.png allows you to merge the Watches and Variables windows together in one. When you do this, the Watches Window is removed from the tabs in the Output Window to avoid redundancy. This feature is often useful when you want to see both together, but probably not the best to leave enabled for performance. This is because the watch has to read the data for all variables and not just the local ones. Select the icon again and the watches will return to their own tab.

blue jewel icon
Back to top


In addition to local variables, access to Global Variables and PIC® Special Function Registers (SFRs) is commonly needed during a debug session. The Variables Window has the capability of displaying watches ( i.e. Global Variables and SFRs) in addition to local variables. Accessing watches in the Variables Window is accomplished using the two lower control icons. The center icon ShowWatches.png controls whether or not to show watches in the Variables Window. When watches are enabled, the lowest control icon CreateNewWatch.png becomes active and you can click on it to enter a new watch into the Variables Window.

The image below shows a screenshot of an SFR being displayed in the Variables Window.

watches and local variables

Local variables will be displayed next to a green rhombus Window_Debugging_Variables.png while watches will be displayed using a diamond icon Window_Debugging_Watches.png.

Viewing Array Segment

You can separate an array to be able to watch just a segment of data. If you have a large buffer, you can focus on just a few elements by providing the direct indexes of what you want to view, for example: [200:202].
array in watches


In order to use the Watches Window, MPLAB® X must be in operating in a debug session Main_Debug_Project.png

Open the Watches Window (Alt + Shift + 2).

window debugging Watches

Right click anywhere on the Watches Window and select New Watch.

add a watch

Select the name of the array you are interested in. Next to the name of the array enter the open bracket symbol "[", followed by the closing bracket "]". Inside the brackets, type in the starting and ending indexes of the array elements you want to view, separating them with a colon. Lastly, click OK.

new watch

You should now see the selected elements in the Watches window.

selected elements

Back to top

Viewing an Element in a Structure

You can select an element within a deep structure and create a fixed watch out of it. This will bring this element out to the top level. It prevents you from having to look in a long list of data to find the variable you want to focus on.
create as a fixed watch


Scroll up/down to find the watch you are interested in.

Right-click on it and then select Create As Fixed Watch.

create as a fixed watch

Once you have added a fixed watch, a top-level watch for this specific element will be immediately created.

fixed watch

Back to top

Collecting Specific Watches in Groups Using Alternate Watch Views

The Watches Window has alternate watch list views which work similarly to having tabbed watches. With alternate views, you can collect specific watches in groups and when you click on a watch view diamond, only the variables associated with that view will be displayed. Select that diamond again and it will default to the standard view. This feature works like a filter.
alternate views

You enable this feature by going to Tools > Options > Embedded > Generic Settings. The default is to have one watch window.
tools options

enable alternate watch list


  • Click on one of the numbered diamonds to select it.
  • Double click on the <Enter new watch> message.
    Enter New Watch

  • Type in the name of the watch you are interested in and press Enter.
    • Alternatively, you can right-click inside the Watches Window, select New Watch, scroll down to select the desired watch and click OK.
  • If you want to add more than one watch, enter the second one in the second row and so on.
    Alternate View Array

Once you have added the watch to this view you can return to the initial watches window by clicking the numbered diamond again.
Alt View

Back to top

Learn More

Back to top