English
Language : 

DS51795A Datasheet, PDF (25/98 Pages) Microchip Technology – PICkit™ 3 Programmer/Debugger
Theory of Operation
2.6.1 Sequence of Operations Leading to Debugging
Given that the requirements for debugging (see previous section) are met, these
actions can be performed when the PICkit 3 programmer/debugger is set as the current
debugger from the MPLAB IDE menu (Debugger>Select Tool>PICkit 3):
• The application code is compiled/assembled by selecting Project>Build
Configuration>Debug.
• When Debugger>Program is selected, the application code is programmed into
the device’s memory via the ICSP protocol as described above.
• A small “debug executive” program is loaded into the high area of program
memory of the target device automatically by MPLAB IDE. Since the debug
executive must reside in program memory, the application program must not use
this reserved space. Some devices have special memory areas dedicated to the
debug executive. Check your device data sheet for details.
• Special “in-circuit debug” registers in the target device are enabled. These allow
the debug executive to be activated by the debugger.
• The target device is held in reset by keeping the VPP/MCLR line low.
2.6.2 Debugging Details
Figure 2-7 illustrates the PICkit 3 programmer/debugger system when it is ready for
debugging.
FIGURE 2-7:
PICkit™ 3 DEBUGGER READY FOR DEBUGGING
+12V
+5V
Internal Circuits
4.7 kΩ
4.7 kΩ
VDD
1
VPP/MCLR
PGC
5
4
PGD
Hardware
Stack Shared
by Debug Exec
Internal
Debug
Registers
Debug
Executive
Program
Memory
Target
must
be
Running
for Debug
Executive
to Function
Area
Reserved
for Debug
Executive
Area Used by
Debug Exec
File
Registers
Typically, in order to find out if 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 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 Debugger>Run function or the Run icon (forward arrow) is usually pressed
from MPLAB IDE. The debugger will then tell the debug executive to run. The target
will start from the reset vector and execute until the Program Counter reaches the
breakpoint address previously stored 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
© 2009 Microchip Technology Inc.
DS51795A-page 21