USING BREAKPOINTS

3.18 USING BREAKPOINTS

Breakpoints allow you to specify conditional program halts so that you may observe memory, register or variable values after a run-time execution. You may set breakpoints in either the file (editor) window, the program memory window or the disassembly window.

3.18.1 Breakpoint Setup

There are several ways to set up breakpoints:

1. Double-click in Gutter – Double-click in the window gutter next to the line of code where you want the breakpoint. Double-click again to remove the breakpoint.

2. Pop-up Menu – Place the cursor over the line of code where you want the breakpoint. Then, right-click to pop up a menu and select Set Breakpoint. Once

a breakpoint is set, Set Breakpoint will become Remove Breakpoint and Disable breakpoint. Other options on the pop-up menu under Breakpoints are for deleting, enabling or disabling all breakpoints.

3. Breakpoint Dialog – Open the Breakpoint dialog (Debugger>Breakpoints) to set, delete, enable or disable breakpoints. You must select a debug tool before this option is available.

3.18.2 Breakpoint Symbols

Symbols relating to breakpoint operation are displayed in the gutter of each supported window. For information on these symbols, see Section 8.3 “Code Display Window Symbols”.

 2005 Microchip Technology Inc.

DS51519A-page 57

MPLAB ® IDE User’s Guide

3.18.3 Breakpoints in Code

Breakpoints will auto-adjust when source code is modified. This means: • Breakpoints set on addresses will stay with those addresses, regardless of the

code associated with that address. • Breakpoints set on source code lines will move with those lines of code.

When setting breakpoints in C code, care must be taken if switching between the C code listing and the associated assembly listing when debugging.

• When you set a breakpoint on a line of C code, a breakpoint is set at the first corresponding line of assembly code as well. Both listing displays will show a red breakpoint symbol at the corresponding line of code.

• When you set a breakpoint in the assembly listing on any line of assembly code that represents a single line of C code, a red breakpoint symbol will appear next to the assembly code line and a yellow breakpoint symbol will appear next to the line of C code.

• When you delete a breakpoint in the Program Memory window on any line of assembly code that represents a single line of C code, the red breakpoint symbol will disappear next to the assembly code line but the yellow breakpoint symbol will remain next to the line of C code until all corresponding assembly code breakpoints are deleted.

3.18.4 Breakpoints and MPLAB ICD 2

MPLAB ICD 2 in-circuit debugger supports a limited amount of breakpoints. The number available are displayed in the Breakpoint dialog (Debugger>Breakpoints).

Tutorial Step 17: To run your program again using a breakpoint:

• Select Debugger>Reset>Processor Reset to reset your application. • Set a breakpoint by double-clicking in the gutter next to the following line of code:

incf COUNT,F ;increment count • Select Debugger>Run to run your program. Program execution should stop at the breakpoint. The values for all items in the Watch window should be 0x00. You may step through your code from this point to watch the values in the Watch window change again.