User manual

Tutorial
© 2008 Microchip Technology Inc. DS51616B-page 41
4.10 RUNNING DEBUG CODE
The MPLAB REAL ICE in-circuit emulator 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 exe-
cution.
5. When the emulator 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 accord-
ingly.
2. Repeat as needed.
The step functions “Step Over” and “Step Out” are used with functions and discussed
in the MPLAB IDE documentation.
4.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
REAL ICE in-circuit emulator. The first debug feature to be discussed are breakpoints.
Breakpoints stop code execution at a selected line of code.
The number of hardware and software breakpoints available and/or used is displayed
in the Device Debug Resource toolbar. See the MPLAB IDE documentation for more
on this feature.
Setting Software Breakpoints
Debugger
Menu
Run Halt Animate Step
Into
Step
Over
Step
Out
Reset
Toolbar
Buttons