User Guide

MPLAB
®
PICkit™ 4 User’s Guide
DS50002751C-page 22 2018 Microchip Technology Inc.
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, such as no oscillator, a faulty power supply connection, shorts on the
target board, etc., then the debug executive cannot communicate to the MPLAB
PICkit 4 In-Circuit Debugger and MPLAB X IDE will issue an error message.
Another way to get a breakpoint is to select Debug>Pause
. This toggles the PGC and
PGD lines so that the in-circuit debug mechanism of the target device switches the
Program Counter from the user’s code in program memory to the debug executive.
Again, the target application program is effectively halted, and MPLAB X IDE uses the
debugger communications with the debug executive to interrogate the state of the
target device.
2.6 PROGRAMMING
In MPLAB X IDE, use the MPLAB PICkit 4 as a programmer to program a non-ICE/-ICD
device, i.e., a device not on a header board. Set the MPLAB PICkit 4 debugger as the
current tool (click the Debug Tool PICkit 4 in the navigation window, then select
F
ile>Project Properties to open the dialog, then under “Hardware Tool,” click PICkit 4)
to perform these actions:
When the Run Main Project icon (see below) is selected, the application code is
programmed into the device’s memory via the ICSP protocol. No clock is required
while programming and all modes of the processor can be programmed, including
code protect, Watchdog Timer enabled and table read protect.
FIGURE 2-10: RUN MAIN PROJECT ICON
A small “program executive” program may be loaded into the high area of
program memory for some target devices.
Special “in-circuit debug” registers in the target device are disabled by MPLAB X
IDE, along with all debug features. This means that a breakpoint cannot be set,
and register contents cannot be seen or altered.
The target device is run in Release mode. As a programmer, the debugger can
only toggle the MCLR
line to Reset and start the target.
The MPLAB PICkit 4 In-Circuit Debugger system programs the target using ICSP. V
PP,
PGC and PGD lines should be connected as described previously. No clock is required
while programming, and all modes of the processor can be programmed, including
code protection, Watchdog Timer and table read protection.
Note: For information on programming, refer to the MPLAB X IDE online Help.