User manual
MPLAB
®
ICD 3 In-Circuit Debugger User’s Guide
DS51766A-page 40 © 2008 Microchip Technology Inc.
5.10 RUNNING DEBUG CODE
The MPLAB ICD 3 in-circuit debugger executes in Real Time or in Step mode.
• Real Time execution occurs when the device is put in the MPLAB IDE’s Run
mode.
• Step mode execution can be accessed after the processor is halted.
These toolbar buttons can be used for quick access to commonly-used debug
operations.
Begin in Real-Time mode:
1. Open the source files counter.c and timer.c (double click on the file names
in the Project window or use File>Open
).
2. Select Debugger>Run
(or click the Run toolbar button).
3. Observe the LEDs. They will be counting up in binary.
4. Select Debugger>Halt
(or click the Halt toolbar button) to stop the program
execution.
5. When the debugger halts, one of the open source code windows will pop to the
front and a green arrow will indicate where the program halted.
To use Step mode:
1. Select Debugger>Step Into
(or click the Step Into toolbar button) to execute one
instruction and then halt. The green arrow in the code listing will move
accordingly.
2. Repeat as needed.
The step functions “Step Over” and “Step Out” are used with functions and discussed
in the MPLAB IDE documentation.
5.11 DEBUGGING CODE USING BREAKPOINTS
The example code in this tutorial has already been debugged and works as expected.
However, this code is still useful to demonstrate the debugging features of the MPLAB
ICD 3 in-circuit debugger. The first debug feature to be discussed are breakpoints.
Breakpoints stop code execution at a selected line of code.
• Setting Software Breakpoints
5.11.1 Choosing a Breakpoint Type
For the device used in this tutorial, you have the choice of using either hardware or
software breakpoints.
To set breakpoint options, select Debugger>Settings
and click on the Configuration
tab. Select the type of breakpoint that best suits your application needs. For this tutorial,
we will begin using the default breakpoint type (hardware breakpoints.)
Debugger
Menu
Run Halt Animate Step Into Step Over Step Out Reset
Toolbar
Buttons