User manual
MPLAB
®
X PICkit™ 3 User’s Guide
DS52116A-page 26 2013 Microchip Technology Inc.
2.7.2 Debugging Details
Figure 2-7 illustrates the PICkit 3 In-Circuit Debugger/Programmer system when it is
ready to perform debugging.
FIGURE 2-7: PICkit™ 3 DEBUGGER READY FOR DEBUGGING
Typically, to find out whether an application program will run correctly, a breakpoint is
set early in the program code. When a breakpoint is set from the user interface of
MPLAB X IDE, the address of the breakpoint is stored in the special internal debug
registers of the target device. Commands on PGC and PGD communicate directly to
these registers to set the breakpoint address.
Next, the Debug>Debug Project
function is selected in MPLAB X IDE. The debugger
tells the debug executive to run. The target starts from the Reset vector and executes
until the program counter reaches the breakpoint address that was stored previously in
the internal debug registers.
After the instruction at the breakpoint address is executed, the in-circuit debug
mechanism of the target device “fires” and transfers the device’s program counter to
the debug executive (much like an interrupt) and the user’s application is effectively
halted. The debugger communicates with the debug executive via PGC and PGD, gets
the breakpoint status information, and sends it back to MPLAB X IDE. MPLAB X IDE
then sends a series of queries to the debugger to get information about the target
device, such as file register contents and the state of the CPU. These queries are
ultimately performed by the debug executive.
The debug executive runs just like an application in program memory. It uses some
locations on the stack for its temporary variables. If the device does not run, for
whatever reason, i.e., no oscillator, faulty power supply connection, shorts on the target
board, etc., then the debug executive cannot communicate to the PICkit 3 In-Circuit
Debugger/Programmer, and MPLAB X IDE will issue an error message.
+5V
+12V
4.7 k
4.7 k
Internal Circuits
Program
Memory
File
Registers
Internal
Debug
Registers
V
PP
/MCLR
PGC
PGD
1
5
4
Executive
Debug
Area Used by
Ta r ge t
be
Running
must
for Debug
Executive
to Function
Area
V
DD
Hardware
Stack Shared
by Debug Exec
Debug Exec
Reserved
for Debug
Executive