WATCH WINDOW

8.12 WATCH WINDOW

The Watch window allows you to monitor program symbols while running your program. Up to four different watches may be set up on different tabs of this window.

• Watch Window Display • Watch Window Menu • Watch Window FAQ

8.12.1 Watch Window Display

Data is displayed in the following columns: • Address – Hexadecimal address of the SFR or Symbol.

To add an absolute address to a Watch view, click in the Address column of the first available row and enter a hex address.

• Symbol Name – Name of the SFR or Symbol. To add a special function register to a Watch view, select the SFR from the

drop-down list and then click Add SFR. To add a symbol to a Watch view, select the symbol from the drop-down list and then click Add Symbol.

• Value – Current value of the SFR or Symbol. To change a value in a Watch view, click in the Value column and type the new

value. Then click outside the column to see the value update. You may add radix information to the display (i.e., Hex, Decimal, Binary, Char) by

right-clicking on the column header bar.

Watch variables may be rearranged using drag-and-drop. Also, you may drag-and-drop SFR's or symbols from the SFR, File Register or Editor window to the Watch window. Conversely, you may drag-and-drop items from the Watch window to the Editor window.

The Watch window now has sorting capability for all columns.

You may select and set up any one of four Watch views by clicking on one of the buttons on the lower left of the window.

DS51519A-page 118

 2005 Microchip Technology Inc.

MPLAB IDE Windows

Watch Window – C Language Usage If you are developing your application code in C, the following features are available to

you: • Bitfield value mouseover available. Enable/disable this feature using the

right-mouse button menu in the Watch window. The Watch window must be the active window (in focus) for this feature to work.

• Click in the Symbol Name field and enter a pointer name, e.g., *count. The variable must be a pointer to an intrinsic type or structure.

• Click in the Symbol Name field and enter a structure member name, e.g., porta.ra0. The variable must be of the form struct.membername. • Click in the Symbol Name field and enter a structure pointer member name, e.g., porta->pin. The variable must be of the form struct->pointername.

Symbol names may be typed, copied/pasted or dragged/dropped. Also, you can select from the SFR/Symbol lists, and then edit the Symbol name to add the extra info.

Note: The watch window will display only 32 bits for MPLAB C30 type long long int and only 16 bits for MPLAB C18 type short long int. Change the display through the Watch dialog.

Example 1: int J = 2;

int* pint = &J; Enter in Watch: *pInt, Value: 2 Example 2: char[] string = "Test";

char* pstring = string; Enter in Watch: *pstring, Value: "Test" Example 3: typedef struct

{ int str_int; char str_ch; } TestStruct; TestStruct struct1;

TestStruct* pstruct1 = &struct1; pstruct1->str_ch = 'A';

Enter in Watch: *pstruct1, Value: tree for struct. Enter in Watch: struct1.str_int, Value: 'A'

 2005 Microchip Technology Inc.

DS51519A-page 119

MPLAB ® IDE User’s Guide

8.12.2 Watch Window Menu

Below are the menu items in the Watch window right mouse button menu. • Close

Close this window. • Find Find text specified in the Find dialog in this window. • Find Next Find the next instance of Find text. F3 repeats the last Find. Shift+F3 reverses the direction of the last Find.

• Add Add a Watch item to the currently-selected Watch tab. See Section 9.3 “Add

Watch Dialog”. • Delete Delete the selected Watch item from the currently-selected Watch tab. • Save Watch Tab

Save the contents of the currently-select Watch tab to a file. • Load Watch Tab Load the contents of a file containing previously-saved Watch information into the

currently-selected tab. • Add Watch Tab Add a Watch tab to the Watch window. You can have as many as 16 Watch tabs. • Rename Watch Tab Rename the currently-selected Watch tab. • Remove Watch Tab Remove the currently-selected Watch tab. You can have no fewer than four Watch

tabs. • Import Table Save Watch data to a table. See Section 9.23 “Table Setup Dialog”. • Export Table Load Watch data from a table. See Section 9.23 “Table Setup Dialog”. • Output to File Write the displayed window contents to a text file. • Print Print the contents of the window. • Refresh Refresh the data in this window. • Properties Opens the Watch dialog, so you can set up fonts and colors, as well as other

Watch window properties. See Section 9.26 “Watch Dialog”.

DS51519A-page 120

 2005 Microchip Technology Inc.

MPLAB IDE Windows

8.12.3 Watch Window FAQ

How do I: • Add a watch (address, SFR or symbol) to a watch window?

Select the Watch window you want by clicking on the appropriate button in the bottom of the window.

To add a watch at a specific address, click in the Address column of the first available row and enter a hex address.

To add a special function register to a Watch view, select the SFR from the list next to the Add SFR button and then click on the button. To add a symbol to a Watch view, select the symbol from the list next to the Add Symbol button and then click on the button.

• Save the watch contents to a file? Click the right mouse button in the window to open a menu. Select Save Watch to

save the currently selected watch to a file. Or, select Export to save Watch values to a file.

• Load a previously saved watch window? Click the right mouse button in the window to open a menu. Select Load Watch to

load a previously saved watch into the currently selected watch. Or, select Import to load Watch values.

• Change the order of watch items? Simply drag and drop items where you want them in the watch list. • Watch a single bit from a register? See Section 9.26 “Watch Dialog”. • Watch C pointers and structure members? See Watch Window – C Language Usage.