Document Layout This document describes how to use the MPLAB PICkit 4 In-Circuit Debugger as a development tool to emulate and debug firmware on a target board, as well as how to program devices. The document is organized as follows: •...
MPLAB PICkit 4 Quick Start Guide Poster (DS50002721) This poster shows you how to connect the hardware and install the software for the MPLAB PICkit 4 In-Circuit Debugger using standard communications and a target board.
MPLAB X Integrated Development Environment (IDE). The MPLAB PICkit 4 is connected to the design engineer's computer using a high-speed 2.0 USB interface and can be connected to the target via a Microchip debug 8-pin Single In-Line (SIL) connector. The connector uses two device ™...
The components of the MPLAB PICkit 4 In-Circuit Debugger system are: • A rectangular-shaped MPLAB PICkit 4 unit housed in a durable, black plastic case with a brushed metal top which is accented with an indicator light strip, button area.
About the Debugger • (Part Number AC002015) - a connectivity board that supports JTAG, SWD and ICSP protocols, useful for ® debugging legacy AVR with MPLAB PICkit 4 (https://www.microchipdirect.com/product/search/all/AC102015). • Transition sockets. • ICD headers. • MPLAB processor extension paks.
Operation A simplified theory of operation of the MPLAB PICkit 4 In-Circuit Debugger system is provided here. It is intended to provide enough information so that a target board can be designed that is compatible with the debugger for both debugging and programming operations.
Important: Refer to the data sheet for the device you are using as well as the application notes and the specific interface for additional information and diagrams. 3.2.1 Standard Communication Target Connection USING SINGLE IN-LINE CONNECTOR Use the single in-line connector between the MPLAB PICkit 4 In-Circuit Debugger and the target board connector (see Figure 3-1 Standard Communication).
Page 12
USING AN ADAPTER Use the AC164110 adapter between the MPLAB PICkit 4 In-Circuit Debugger and the target device with the modular interface (six conductor) cable. The pin numbering for the connector is shown from the bottom of the target PCB in Figure 3-3.
Debugging There are two steps to using the MPLAB PICkit 4 In-Circuit Debugger system as a debugger. The first requires that an application is programmed into the target device (usually with the MPLAB PICkit 4 itself). The second uses the internal in-circuit debug hardware of the target Flash device to run and test the application program.
PGC and data is read back from PGD. This sequence confirms the debugger and device are communicating correctly. Requirements for Debugging To debug (set breakpoints, see registers, etc.) with the MPLAB PICkit 4 In-Circuit Debugger system, there are critical elements that must be working correctly: •...
Page 16
Debugger. • The target device is run in Debug mode. 3.4.2 Debugging Details The figure below illustrates the MPLAB PICkit 4 In-Circuit Debugger system when it is ready to begin debugging. ® ™ Figure 3-9. MPLAB PICkit 4 In-Circuit Debugger Ready to Begin Debugging To find out whether an application program will run correctly, a breakpoint is typically set early in the program code.
Notice: Headers are not supported at this time. In MPLAB X IDE, use the MPLAB PICkit 4 as a programmer to program a non-ICE/-ICD device, such as a device not on a header board. Set the MPLAB PICkit 4 In-Circuit Debugger as the current tool (click the Debug Tool PICkit 4 in the navigation window, select File >...
Debugger Usage Notice: For header support, see the Release Notes for MPLAB PICkit 4 in MPLAB X IDE v5.25 or greater. Table 4-1. Debug vs. Program Operation Item Debug Program Needed Hardware A computer and target application (Microchip demo board or your own design).
4.7.2 Using ICE Devices Notice: For header support, see the latest Release Notes for MPLAB PICkit 4 in MPLAB X IDE v5.25 or greater. For ICE devices, an ICE header board is required. The header board contains the hardware that is necessary to emulate a specific device or family of devices.
Board). Then power the target. Setting Up MPLAB X IDE Once the hardware is connected and powered, MPLAB X IDE may be set up for use with the MPLAB PICkit 4 In- Circuit Debugger. On some devices, you must select the communications channel in the Configuration bits, for example, PGC1/EMUC1 and PGD1/EMUD1.
When Connected to Computer When the MPLAB PICkit 4 is connected to the computer and in the MPLAB X IDE or MPLAB IPE application, use the supplied USB cable between the computer and the Micro-B USB connector located on the top of the tool.
Go, the minimum power required from the target board to the MPLAB PICkit 4 is 350 mA. If sufficient power cannot be supplied from the target board, then MPLAB PICkit 4 must be powered by a 5V power supply through the Micro-B USB connector on the top of the MPLAB PICkit 4 tool. There are several options for providing power, such as, using: •...
5.3.1 Setting Up PTG Mode Using MPLAB X IDE Using MPLAB X IDE, follow these steps to download the project files into the microSDHC card in the MPLAB PICkit 4 and enter Programmer-To-Go mode. Insert a formatted FAT32-compatible microSDHC card into the PICkit 4.
Page 27
In the Send image to tool, the check box is selected by default. With the box checked, the PTG image is created and then sent to the microSDHC card in the connected MPLAB PICkit 4. The Program Device check box is selected by default. When the check box selected, the device connected to the MPLAB PICkit 4 is programmed.
Page 28
5.3.2 Setting Up PTG Mode with MPLAB IPE Using MPLAB IPE, follow these steps to download the project files into the microSDHC card in the MPLAB PICkit 4 and enter Programmer-To-Go mode. Insert a formatted FAT32-compatible microSDHC card into the PICkit. 4.
Page 29
In the Send image to tool, the check box is selected by default. With the check box selected, the PTG image is created and then sent to the microSDHC card in the connected MPLAB PICkit 4. The Program Device the check box is selected by default. With the box checked, the device connected to the MPLAB PICkit 4 is programmed.
Remember, in order to use PTG, you must have a microSDHC card, with the necessary image inserted in the PICkit Using Programmer-To-Go When you are ready to start programming devices using the MPLAB PICkit 4 in PTG mode, complete the following steps: Connect the PICkit 4 tool, with a microSDHC card inserted, to the target board with the device specified in your project.
Exiting Programmer-To-Go Mode To exit from Programmer-To-Go mode, plug the MPLAB PICkit 4 unit into a PC USB port and connect to MPLAB X IDE or MPLAB IPE. Initiate any non-PTG operation (for example, Program, Erase, etc.) and the following message displays: “The PICkit 4 is currently in programmer to go mode.
Troubleshooting Troubleshooting If you are having problems with MPLAB PICkit 4 In-Circuit Debugger operation, start here. Some Questions to Answer First Which device are you working with? Often an upgrade to a newer version of MPLAB X IDE is required to support newer devices.
Page 34
Disconnect the Micro-B USB cable from the debugger. Press down on the MPLAB PICkit 4 logo and hold while plugging in the Micro-B USB cable. The light strip flashes purple. Continue pressing the logo until the light strip stops flashing and changes to steady on purple.
Page 35
Troubleshooting Figure 6-3. Emergency Recovery Button If the procedure was successful, the recovery wizard displays a success screen. The MPLAB PICkit 4 will now be operational and able to communicate with the MPLAB X IDE. If the procedure failed, try it again. If it fails a second time, contact Microchip Support at https:// support.microchip.com.
No. The device will run at any device speed as specified in the data sheet. Is it possible to debug a dsPIC DSC device running at any speed? The MPLAB PICkit 4 In-Circuit Debugger is capable of debugging at any device speed as specified in the device’s data sheet.
Error Messages Error Messages The MPLAB PICkit 4 In-Circuit Debugger produces various error messages; some are specific and others can be resolved with general corrective actions. In general, read any instructions under your error message. If these fail to fix the problem or if there are no instructions, refer to the following sections.
Page 39
8.1.4 Miscellaneous Errors MPLAB PICkit 4 is busy. Please wait for the current operation to finish. If you receive this error when attamepting to deselect the debugger as a debugger or programmer: Wait. Give the debugger time to finish any application tasks. Then try to deselect the debugger again.
Ensure that the cable(s) are of the correct length. 8.2.3 Debugger to Computer Communication Error Actions If the MPLAB PICkit 4 In-Circuit Debugger and MPLAB X IDE or MPLAB IPE are not communicating with each other: Unplug and then plug in the debugger. Reconnect to the debugger.
Page 48
Error Messages 8.2.6 Debug Failure Actions The MPLAB PICkit 4 In-Circuit Debugger was unable to perform a debugging operation. There are numerous reasons why this might occur. See 6.2 Top Reasons Why You Can't Debug 6.3 Other Things to Consider.
Debugger Function Summary Debugger Function Summary A summary of the MPLAB PICkit 4 In-Circuit Debugger functions are summarized below. 10.1 Debugger Selection and Switching Use the Project Properties dialog to select or switch debuggers for a project. To switch you must have more than one debugger connected to your computer.
Page 54
This check box is selected by default. With the box checked, the PTG image is created and then tool sent to the microSDHC card in the connected MPLAB PICkit 4. Program Device This check box is selected by default. With the box checked, the device connected to the MPLAB PICkit 4 is programmed.
Page 55
Interface (UPDI). On low pin count AVR devices with UPDI, the UPDI pin can be configured as GPIO or RESET by configuring the RSTPINCFG configuration bits. To do further programming, the MPLAB PICkit 4 will have to use a high voltage pulse to reactivate the UPDI interface. When using the high voltage pulse, you must make sure that all circuits connected to the UPDI wire can tolerate a pulse of at least 12V.
11.1 USB Connector The MPLAB PICkit 4 In-Circuit Debugger is connected to the host computer via a Micro-B USB connector, version 2.0 compliant. The Micro-B USB connector is located on the top of the debugger. The system is capable of reloading the firmware via the USB interface.
Page 59
The clock and data connections are interfaces with the following characteristics: • Clock and data signals are in high-impedance mode (even when no power is applied to the MPLAB PICkit 4 In- Circuit Debugger system). • Clock and data signals are protected from high voltages caused by faulty target systems, or improper connections.
Page 60
Note: Refer to the data sheet for the device you are using as well as the application notes for the specific interface for additional information and diagrams. Table 11-5. Pinouts for Debug Interfaces MPLAB PICkit 4 DEBUG ® ®...
Revision A (May 2018) Initial release of this document. 12.2 Revision B (August 2018) • Added information on the Debug Adapter Board in 2.3 MPLAB PICkit 4 In-Circuit Debugger Components. • Expanded Table 11-5 table to include pinouts for additional interfaces.
) Integrated Development Environment for development systems tools. • Programmers – The latest information on Microchip programmers. These include the device (production) programmers MPLAB REAL ICE in-circuit emulator, MPLAB ICD 4 in-circuit debugger, MPLAB PICkit 4 in-circuit debugger, MPLAB PM3 and development (non-production) programmers PICkit 3. •...
Page 74
™ MPASM Assembler ® Microchip Technology’s relocatable macro assembler for PIC microcontroller devices, KeeLoq devices and Microchip memory devices. MPLAB Language Tool for Device Microchip’s C compilers, assemblers and linkers for specified devices. Select the type of language tool based on the device you will be using for your application, e.g., if you will be creating C code on a PIC18 MCU, select the MPLAB...
SQTP is a service mark of Microchip Technology Incorporated in the U.S.A. Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries. GestIC is a registered trademark of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in other countries.
Need help?
Do you have a question about the MPLAB PICkit 4 and is the answer not in the manual?
Questions and answers