5.18 Watch Symbol Values Change

Watch the values of symbols that you have selected change in the Watches window. Knowing whether these values are set as expected during program execution will help you to debug your code.

The following symbols may be added to a Watches window:

  • Global symbols – visible after a build
  • SFRs – special function registers (device dependent)
  • Absolute addresses

In general, you must Pause from debugging to be able to see updated values. 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.

For all devices except PIC32 MCUs, symbols used in a runtime watch must be sized to match the device memory. That is, you need 8-bit symbols when using an 8-bit device.

For C-language enumerated types, you may enter either the enum label (text) or integer value in the window. For labels, be aware that they are case sensitive.

Figure 5-36. Watches Window – Program Pause

To view the Watches window do one of the following:

  • Select Window > Debugging > Watches to open the window.
  • If the window is already open, click the Watches tab in the Output window.

To create a new watch directly:

You can add a symbol directly to the Watches window by doing one of the following:

  • Double click in the name column and type in a global symbol, SFR, or absolute address (0x300).
  • Right click on a global symbol or SFR in the Editor window and select New Watch.
  • Select the global symbol or SFR in the Editor window and drag-and-drop it into the Watches window.

To create a new watch using the New Watch dialog:

You can add a symbol or SFR to the Watches window by doing one of the following:

  • Right click in the Watches window and select New Watch or select Debug > New Watch. Click the selection buttons to see either Global Symbols or SFRs. Click on a name from the list and then click OK.
  • Select the symbol or SFR name in the Editor window and then select New Watch from the right click menu. The name will be populated in the window. Click OK.

To create a new runtime watch:

Before you add a runtime watch to the Watches window, you need to set up the clock:

  1. Right click on the project name and select Properties.
  2. Click on the debug tool name (e.g., PICkit 4), and select the Clock option category.
  3. Set the runtime instruction speed.

To add a global symbol or SFR as a runtime watch, follow the instructions under To create a new watch using the New Watch dialog except select New Runtime Watch instead of New Watch.

For all devices except PIC32 MCUs, symbols used in a runtime watch must be sized to match the device memory. That is, you need 8-bit symbols when using an 8-bit device.

To view symbol changes:

  1. Debug and then Pause your program.
  2. Click the Watches tab to make the window active.
  3. For watch symbols, continue the debug session and Pause to see changing values. For runtime watch symbols, continue Debug and watch the values change as the program executes.

You must be in a debug session to see the values of symbols – global symbols, SFRs, arrays, register bitfields, etc.

Note: You cannot view the value of macros in this way. Use the Macro Expansion Window by right clicking on the macro in the editor during debug.

To change the radix of a watch symbol:

Right click in the line of the symbol and select Display Value As.

To perform other tasks:

For more on watches, see 14.30 Watches Window.