Watching Symbol Values Change

Watch the values of global symbols or SFRs change in the Watches window. Determining if these values are as expected during program execution will help you to debug your code.

Edit the Code

Click the “Finish Debugger Session” icon .

Currently pot_value is a local symbol. To make it a global symbol, declare it before main().

#include "mcc_generated_files/mcc.h"
uint16_t pot_value;
/*                         Main application
 */
void main(void)

Then remove uint16_t from the line that contains the first usage of this symbol.

    while (1)
    {
        // Add your application code
        pot_value = ADCC_GetSingleConversion(POT);

Place a breakpoint at this line and again click the “Debug Project” icon . The program should halt on this line.

Create a New Watch

To create a new watch:

  1. 1.Select Debug>New Watch. The New Watch dialog will open.
  2. 2.Enter a Watch expression, in this case pot_value, and then click OK. The Watches window will now appear on the desktop with the symbol.
Figure 1. New Watch Symbol

View Value Changes in Watches Window

Click the “Debug Project” icon . The code will execute and stop at the breakpoint. pot_value information will be shown in the Watches window.

Figure 2. Watches Window - First Breakpoint Halt

Turn the pot on the board so the value will change. Click the “Continue” icon . The code will execute and stop at the breakpoint again. View the Watches window to see that the value has changed.

Figure 3. Watches Window - Second Breakpoint Halt

For more on this window, see Watches Window.