Datasheet

PICkit™ 3 Debug Express
DS41370C-page 38 © 2009 Microchip Technology Inc.
3.6.2 Selecting PICkit 3 as a Debugger in the MPLAB IDE
The PICkit 3 cannot be used as a programmer and debugger at the same time, so if
PICkit 3 is currently selected as a programmer, selecting it as a debugger will cause it
to be disabled as a programmer.
To enable the PICkit 3 as a debugger in the MPLAB IDE select Debugger > Select Tool
> 2 PICkit 3. The Output window will display the connection to the target microcontroller
as in Figure 3-10A.
To Begin Debugging
In the MPLAD IDE toolbar, change the project configuration from “Rlease” to
“Debug”.
Build the project: Project > Build All
Program the target microcontroller: Debugger > Program
•Select Debugger > Run to begin program execution.
The Lesson 5 code is now running in Debug mode. The LEDs will rotate and the button
may be pressed to reverse them, as the target microcontroller will operate in Debug
mode just as it normally would.
3.6.3 Basic Debug Operations
3.6.3.1 HALT
The PIC18F45K20 on the demo board is now running the lesson program code. Code
execution can be halted (stopped) at any time by selecting Debugger > Halt
<F5>. A
green arrow on the left margin of the MPLAB IDE editor window will show the next
statement to be executed. Your code will probably have stopped in a different place
than that shown in Figure 3-27.
FIGURE 3-27: GREEN ARROW POINTS TO NEXT STATEMENT TO EXECUTE
Note: An ICD ‘i’ Linker Script must be used when debugging, as discussed in
Section 3.1.1 of this document. The lesson projects already use the correct
Linker Script, 18f45k20 i.lkr.