Difference Between Watches and Variables Windows

Last modified by Microchip on 2023/11/09 09:11

Both the Watches and Variables windows are used to view and modify microcontroller (MCU) data memory during a debug session. The difference between the two windows is the type of variable that can be viewed in each.

Watches WindowVariables Window
Global variablesLocal variables
Peripheral configuration registersFunction parameters
Static local variables 

The Watches window can only view variables and MCU registers that have a permanent memory address. These include global variables (variables defined outside of any function), peripheral configuration registers (also known as special function registers or SFRs), and local variables defined as static.

global example

The Variables window is used to view local variables. These variables are defined inside functions and are created (allocated on the stack) when a function is called and destroyed (de-allocated from the stack) when the function exits. Local variables do not have a permanent address.

local example

If you want to see all variables in one window, you can add the Watches window content to the Variables window (see the "Watches In Local Variables View" section of the Using the Watches Window to Access Global Variables and Registers (SFRs) page).

​Note the values in these windows are only valid when the debug session is paused. However, some tools allow runtime updates (you can see the values change as your program is running). Check your tool documentation to see if it supports this feature.