Microchip Technology MPLAB® ICD 4 User’s Guide

MPLAB® ICD 4
In-Circuit Debugger
User’s Guide
2017 Microchip Technology Inc. DS50002596A
Note the following details of the code protection feature on Microchip devices:
YSTEM
CERTIFIE DBYDNV
== ISO/TS16949==
Microchip products meet the specification contained in their particular Microchip Data Sheet.
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the intended manner and under normal conditions.
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer’s risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights unless otherwise stated.
Microchip received ISO/TS-16949:2009 certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona; Gresham, Oregon and design centers in California and India. The Company’s quality system processes and procedures are for its PIC devices, Serial EEPROMs, microperipherals, nonvolatile memory and analog products. In addition, Microchip’s quality system for the design and manufacture of development systems is ISO 9001:2000 certified.
®
MCUs and dsPIC® DSCs, KEELOQ
®
code hopping
Trademarks
The Microchip name and logo, the Microchip logo, AnyRate, AVR, AVR logo, AVR Freaks, BeaconThings, BitCloud, CryptoMemory, CryptoRF, dsPIC, FlashFlex, flexPWR, Heldo, JukeBlox, KEELOQ, KEELOQ logo, Kleer, LANCheck, LINK MD, maXStylus, maXTouch, MediaLB, megaAVR, MOST, MOST logo, MPLAB, OptoLyzer, PIC, picoPower, PICSTART, PIC32 logo, Prochip Designer, QTouch, RightTouch, SAM-BA, SpyNIC, SST, SST Logo, SuperFlash, tinyAVR, UNI/O, and XMEGA are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
ClockWorks, The Embedded Control Solutions Company, EtherSynch, Hyper Speed Control, HyperLight Load, IntelliMOS, mTouch, Precision Edge, and Quiet-Wire are registered trademarks of Microchip Technology Incorporated in the U.S.A.
Adjacent Key Suppression, AKS, Analog-for-the-Digital Age, Any Capacitor, AnyIn, AnyOut, BodyCom, chipKIT, chipKIT logo, CodeGuard, CryptoAuthentication, CryptoCompanion, CryptoController, dsPICDEM, dsPICDEM.net, Dynamic Average Matching, DAM, ECAN, EtherGREEN, In-Circuit Serial Programming, ICSP, Inter-Chip Connectivity, JitterBlocker, KleerNet, KleerNet logo, Mindi, MiWi, motorBench, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK, MultiTRAK, NetDetach, Omniscient Code Generation, PICDEM, PICDEM.net, PICkit, PICtail, PureSilicon, QMatrix, RightTouch logo, REAL ICE, Ripple Blocker, SAM-ICE, Serial Quad I/O, SMART-I.S., SQI, SuperSwitcher, SuperSwitcher II, Total Endurance, TSHARC, USBCheck, VariSense, ViewSpan, WiperLock, Wireless DNA, and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
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.
QUALITYMANAGEMENTS
DS50002596A-page 2  2017 Microchip Technology Inc.
ARM and Cortex are registered trademarks of ARM Limited in the EU and other countries.
All other trademarks mentioned herein are property of their respective companies.
© 2017, Microchip Technology Incorporated, All Rights Reserved.
ISBN: 978-1-5224-1585-5

EU Declaration of Conformity

This declaration of conformity is issued by the manufacturer. The development/evaluation tool is designed to be used for research and development in a laboratory environment. This development/evaluation tool is not intended to be a finished appliance, nor is it intended for incorporation into finished appliances that are made commercially available as single functional units to end users. This development/evaluation tool complies with EU EMC Directive 2004/108/EC and as supported by the European Commission's Guide for the EMC Directive 2004/108/EC (8th February 2010). This development/evaluation tool complies with EU RoHS2 Directive 2011/65/EU. This development/evaluation tool, when incorporating wireless and radio-telecom functionality, is in compliance with the essential requirement and other relevant provisions of the R&TTE Directive 1999/5/EC and the FCC rules as stated in the declaration of conformity provided in the module datasheet and the module product page available at www.microchip.com.
For information regarding the exclusive, limited warranties applicable to Microchip products, please see Microchip’s standard terms and
conditions of sale, which are printed on our sales documentation and available at www.microchip.com. Signed for and on behalf of Microchip Technology Inc. at Chandler, Arizona, USA.
Object of Declaration:
Object of Declaration: MPLAB ICD-4 In-Circuit Debugger
2017 Microchip Technology Inc. DS50002596A-page 3
MPLAB® ICD 4 User’s Guide
NOTES:
DS50002596A-page 4  2017 Microchip Technology Inc.
MPLAB® ICD 4 USER’S GUIDE

Table of Contents

Preface ........................................................................................................................... 7
Part 1 – Getting Started
Chapter 1. About the Debugger
1.1 Introduction ................................................................................................... 13
1.2 MPLAB ICD 4 In-Circuit Debugger Description ............................................ 13
1.3 MPLAB ICD 4 In-Circuit Debugger Advantages ........................................... 14
1.4 MPLAB ICD 4 In-Circuit Debugger Components ......................................... 15
1.5 MPLAB ICD 4 Block Diagram ....................................................................... 16
Chapter 2. Operation
2.1 Introduction ................................................................................................... 17
2.2 Debugger to Target Communication ............................................................ 18
2.3 Target Communication Connections ............................................................ 20
2.4 Debugging .................................................................................................... 22
2.5 Requirements for Debugging ....................................................................... 23
2.6 Programming ................................................................................................ 25
2.7 Resources Used by the Debugger ............................................................... 25
Chapter 3. Debugger Usage
3.1 Introduction ................................................................................................... 27
3.2 Installation and Setup ................................................................................... 27
3.3 Debug Tutorial .............................................................................................. 28
3.4 Quick Debug/Program Reference ................................................................ 28
3.5 Debugger Limitations ................................................................................... 28
3.6 Connecting the Target Board ....................................................................... 29
3.7 Setting Up the Target Board ......................................................................... 30
3.8 Starting and Stopping Debugging ................................................................ 31
3.9 Viewing Processor Memory and Files .......................................................... 31
3.10 Breakpoints and Stopwatch ........................................................................ 32
Part 2 – Troubleshooting
Chapter 4. Troubleshooting First Steps
4.1 Introduction ................................................................................................... 37
4.2 The Five Questions to Answer First ............................................................. 37
4.3 Top Reasons Why You Can’t Debug ........................................................... 38
4.4 Other Things to Consider ............................................................................. 39
2017 Microchip Technology Inc. DS50002596A-page 5
MPLAB® ICD 4 User’s Guide
Chapter 5. Frequently Asked Questions (FAQs)
5.1 Introduction ................................................................................................... 41
5.2 How Does It Work? ...................................................................................... 41
5.3 What’s Wrong? ............................................................................................. 42
Chapter 6. Error Messages
6.1 Introduction ................................................................................................... 45
6.2 Specific Error Messages .............................................................................. 45
6.3 General Corrective Actions .......................................................................... 53
6.4 Information Messages .................................................................................. 54
Part 3 – Reference
Appendix A. Debugger Function Summary
A.1 Introduction .................................................................................................. 57
A.2 Debugger Selection and Switching .............................................................. 57
A.3 Debugger Options Selection ........................................................................ 57
Appendix B. Hardware Specification
B.1 Introduction .................................................................................................. 63
B.2 Highlights ..................................................................................................... 63
B.3 USB Port/Communication ............................................................................ 63
B.4 MPLAB ICD 4 In-Circuit Debugger .............................................................. 64
B.5 Standard Communication Hardware ............................................................ 65
B.6 ICD Test Interface Module ........................................................................... 68
B.7 Target Board Considerations ....................................................................... 69
Appendix C. Revision History
Support .........................................................................................................................73
Glossary .......................................................................................................................75
Index .............................................................................................................................95
Worldwide Sales and Service .....................................................................................98
DS50002596A-page 6  2017 Microchip Technology Inc.
MPLAB® ICD 4 USER’S GUIDE

Preface

NOTICE TO CUSTOMERS
All documentation becomes dated, and this manual is no exception. Microchip tools and documentation are constantly evolving to meet customer needs, so some actual dialogs and/or tool descriptions may differ from those in this document. Please refer to our web site (www.microchip.com) to obtain the latest documentation available.
Documents are identified with a “DS” number. This number is located on the bottom of each page, in front of the page number. The numbering convention for the DS number is “DSXXXXXXXXA”, where “XXXXXXXX” is the document number and “A” is the revision level of the document.
For the most up-to-date information on development tools, see the MPLAB Help. Select the Help menu, and then Topics to open a list of available online Help files.

INTRODUCTION

This chapter contains general information that will be useful to know before using the MPLAB ICD 4 In-Circuit Debugger. Items discussed in this chapter include:
Document Layout
Conventions Used in this Guide
Recommended Reading
®
X IDE online
2017 Microchip Technology Inc. DS50002596A-page 7
MPLAB® ICD 4 User’s Guide

DOCUMENT LAYOUT

This document describes how to use the MPLAB ICD 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:
Part 1 – Getting Started
Chapter 1. About the Debugger – What the MPLAB ICD 4 In-Circuit Debugger is
and how it can help you develop your application.
Chapter 2. Operation – The theory of MPLAB ICD 4 In-Circuit Debugger
operation. Explains configuration options.
Chapter 3. Debugger Usage – A description of basic debug features available in
MPLAB X IDE when the MPLAB ICD 4 In-Circuit Debugger is chosen as the debug tool. This includes the debug features for breakpoints and stopwatch.
Part 2 Troubleshooting
Chapter 4. Troubleshooting First Steps – The first things you should try if you
are having issues with debugger operation.
Chapter 5. Frequently Asked Questions (FAQs) – A list of frequently asked
questions, useful for troubleshooting.
Chapter 6. Error Messages – A list of error messages and suggested
resolutions.
Part 3 Reference
Appendix A. Debugger Function Summary – A summary of debugger functions
available in MPLAB X IDE when the MPLAB ICD 4 debugger is chosen as the debug or program tool.
Appendix B. Hardware Specification – The hardware and electrical
specifications of the debugger system.
Appendix C. Revision History
DS50002596A-page 8  2017 Microchip Technology Inc.

CONVENTIONS USED IN THIS GUIDE

This manual uses the following documentation conventions:
DOCUMENTATION CONVENTIONS
Description Represents Examples
Arial font:
Italic characters Referenced books MPLAB® IDE User’s Guide
Initial caps A window the Output window
Quotes A field name in a window or
Underlined, italic text with right angle bracket
Bold characters A dialog button Click OK
N‘Rnnnn A number in verilog format,
Text in angle brackets < > A key on the keyboard Press <Enter>, <F1>
Courier New font:
Plain Courier New Sample source code #define START
Italic Courier New A variable argument file.o, where file can be
Square brackets [ ] Optional arguments mcc18 [options] file
Curly brackets and pipe character: { | }
Ellipses... Replaces repeated text var_name [,
Preface
Emphasized text ...is the only compiler...
A dialog the Settings dialog A menu selection select Enable Programmer
“Save project before build”
dialog A menu path File>Save
A tab Click the Power tab
4‘b0010, 2‘hF1 where N is the total number of digits, R is the radix and n is a digit.
Filenames autoexec.bat File paths c:\mcc18\h Keywords _asm, _endasm, static Command-line options -Opa+, -Opa- Bit values 0, 1 Constants 0xFF, ‘A’
any valid filename
[options]
Choice of mutually exclusive arguments; an OR selection
Represents code supplied by user
errorlevel {0|1}
var_name...]
void main (void)
{ ...
}
2017 Microchip Technology Inc. DS50002596A-page 9
MPLAB® ICD 4 User’s Guide

RECOMMENDED READING

This user's guide describes how to use MPLAB ICD 4 In-Circuit Debugger. Other useful documents are listed below. The following Microchip documents are available and recommended as supplemental reference resources.
Multi-Tool Design Advisory (DS51764)
Please read this first! This document contains important information about
operational issues that should be considered when using the MPLAB ICD 4 with your target design.
Release Notes for MPLAB ICD 4 In-Circuit Debugger
For the latest information on using MPLAB ICD 4 In-Circuit Debugger, read the notes under “Release Notes and Support Documentation” on the MPLAB X IDE Start Page. The release notes contain update information and known issues that may not be included in this user’s guide.
MPLAB ICD 4 Quick Start Guide Poster (DS50002538A)
This poster shows you how to connect the hardware and install the software for the MPLAB ICD 4 In-Circuit Debugger using standard communications and a target board.
MPLAB ICD 4 In-Circuit Debugger Online Help File
A comprehensive help file for the debugger is included with MPLAB X IDE. Usage, troubleshooting and hardware specifications are covered. This help file may be more up-to-date than the printed documentation.
Processor Extension Pak and Header Specification (DS50001292)
This booklet describes how to install and use headers. Headers are used to better debug selected devices, without the loss of pins or resources. See also the PEP and Header online Help file.
Transition Socket Specification (DS51194)
Consult this document for information on transition sockets available for use with headers.
DS50002596A-page 10  2017 Microchip Technology Inc.
MPLAB® ICD 4 USER’S GUIDE

Part 1 – Getting Started

Chapter 1. About the Debugger .................................................................................. 13
Chapter 2. Operation.................................................................................................... 17
Chapter 3. Debugger Usage ........................................................................................ 27
2017 Microchip Technology Inc. DS50002596A-page 11
MPLAB® ICD 4 User’s Guide
NOTES:
DS50002596A-page 12  2017 Microchip Technology Inc.
MPLAB® ICD 4 USER’S GUIDE

Chapter 1. About the Debugger

1.1 INTRODUCTION

An overview of the MPLAB® ICD 4 In-Circuit Debugger system is provided in this chapter.
MPLAB ICD 4 In-Circuit Debugger Description
MPLAB ICD 4 In-Circuit Debugger Advantages
MPLAB ICD 4 In-Circuit Debugger Components
MPLAB ICD 4 Block Diagram

1.2 MPLAB ICD 4 IN-CIRCUIT DEBUGGER DESCRIPTION

The MPLAB ICD 4 In-Circuit Debugger (DV164045) is Microchip’s fastest and most cost-effective debugging and programming tool for Microchip PIC (MCUs) and dsPIC powerful and easy-to-use graphical user interface of MPLAB X Integrated Development Environment (IDE). The MPLAB ICD 4 is connected to your PC through a high-speed USB 3.0-compatible interface and is connected to the target with an RJ-11 connector. The MPLAB ICD 4 also works with JTAG interfaces.
The debugger system executes code like an actual device because it uses a device with built-in emulation circuitry instead of a special debugger chip. All available features of a given device are accessible interactively and can be set and modified by the MPLAB X IDE interface.
The MPLAB ICD 4 In-Circuit Debugger is compatible with any of these platforms:
• Microsoft Windows
• Linux
• Mac OSX™
The MPLAB ICD 4 debugger was developed for debugging embedded processors with rich debug facilities which differ from conventional system processors in the following aspects:
• Processors run at maximum speeds
• Capability to incorporate I/O port data input
• Advanced host communication interfaces (Windows, macOS and Linux)
• Advanced communication mediums and protocols
• Faster programming times
• Modular design (testability and maintainability)
In addition to debugger functions, the MPLAB ICD 4 In-Circuit Debugger system also may be used as a device production programmer.
®
®
Digital Signal Controllers (DSCs). It debugs and programs with the
®
7 or later
®
Microcontrollers
2017 Microchip Technology Inc. DS50002596A-page 13
MPLAB® ICD 4 User’s Guide

1.3 MPLAB ICD 4 IN-CIRCUIT DEBUGGER ADVANTAGES

The MPLAB ICD 4 In-Circuit Debugger system provides the following advantages:

Features/Capabilities:

• Connects to computer via high-speed USB 2.0 (480 Mbits/s) cable
• Comes with a standard Microchip debugging connector (RJ-11) and has the option to use JTAG
• Programs devices using MPLAB X IDE or MPLAB IPE
• Supports multiple breakpoints, stopwatch, and source code file debugging
• Debugs your application on your own hardware in real time
• Sets breakpoints based on internal events
• Monitors internal file registers
• Debugs at full speed
• Configures pin drivers
• Field-upgradeable through an MPLAB X IDE firmware download
• Adds new device support and features by installing the latest version of MPLAB X IDE (available as a free download at www.microchip.com/mplabx)
• Controls brightness of LEDs
• Includes a test module that can test all communications

Performance/Speed:

• More and faster memory
• A Real-Time Operating System (RTOS)
• No firmware download delays incurred when switching devices
• A 32-bit MCU running at 300 MHz
• A buffer memory of 2 MB

Safety:

• Receive feedback from debugger when external power supply is needed for target
• Supports target supply voltages from 1.2V to 5.5V
• Safely power up to 1A with an optional power supply
• Protection circuitries are added to the probe drivers to guard from power surges from the target
•V
DD and VPP voltage monitors protect against overvoltage conditions/all lines
have over-current protection
• Programming/debugging pins are physically isolated via relays until voltage is determined to be safe for connection, programmable resistor value, and direction (pull-up, pull-down, or nonexistent).
• Controlled programming speed provides flexibility to overcome target board design issues
• CE and RoHS compliant – conforms to industry standards
DS50002596A-page 14  2017 Microchip Technology Inc.
About the Debugger
Mini USB Cable
Indicator Bar
Modular Cable to Target Board, Header or ICD
ICD Test Interface Board
Test Interface Board
ICD Test Interface Module
Mini-B USB Cable
Modular Cable

1.4 MPLAB ICD 4 IN-CIRCUIT DEBUGGER COMPONENTS

The components of the MPLAB ICD 4 In-Circuit Debugger system are:
• A puck-shaped MPLAB ICD 4 unit housed in a durable, black case with a brushed aluminum top which is accented with an LED indicator bar, and a Mini-B USB connector, an RJ-45 connector, and a power connector
• A Mini-B USB cable to provide communication between the debugger and a computer, and to provide power from the computer to the debugger
• A 6-inch modular cable (6-pin RJ-11 type) to connect the MPLAB ICD 4 unit to a header module or target board
• An ICD Test Interface Module (AC164113) to self-test the debugger
FIGURE 1-1: BASIC DEBUGGER SYSTEM
2017 Microchip Technology Inc. DS50002596A-page 15
Additional hardware and accessories may be ordered separately from Microchip Direct (http://www.microchipdirect.com):
• Power supply (Part Number AC002014) - to provide up to 1A of power to the target application
• Transition sockets
• ICD headers
• MPLAB processor extension kits
MPLAB® ICD 4 User’s Guide

1.5 MPLAB ICD 4 BLOCK DIAGRAM

DS50002596A-page 16  2017 Microchip Technology Inc.

2.1 INTRODUCTION

A simplified theory of operation of the MPLAB ICD 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. The basic theory of in-circuit debugging and programming is discussed so that problems, if encountered, are quickly resolved.
Debugger to Target Communication
Target Communication Connections
Debugging
Requirements for Debugging
Programming
Resources Used by the Debugger
MPLAB® ICD 4 USER’S GUIDE

Chapter 2. Operation

DS50002596A-page 17  2017 Microchip Technology Inc.
MPLAB® ICD 4 User’s Guide

2.2 DEBUGGER TO TARGET COMMUNICATION

Note: The MPLAB X IDE software must be installed prior to connecting the
MPLAB ICD 4 In-Circuit Debugger.
The debugger is connected to the computer via a USB cable for communication and debugger power (not target power).
The debugger is connected to the target application for communication and data collection. Refer to Section B.5.1 “Connecting an RJ-11 Type Cable to an RJ-45 Socket
on MPLAB ICD 4 In-Circuit Debugger” for pinout information.
The power supply (not included) is connected either to the target application (preferred method) or the debugger to provide power to the target.
The debugger system configurations are discussed in the following sections.
Communication Failure. Do not connect the hardware before installing the software and USB drivers.
CAUTION
CAUTION
Debugger or Target Damage. Do not change hardware connections while the debugger or target is powered.
2.2.1 Standard ICSP Device Communication
The debugger system can be configured to use standard 6-pin ICSP (modular cable) communication connection for both programming and debugging functions. The modular cable can be inserted into either:
•a matching socket at the target, where the target device is on the target board (Figure 2-1), or
• a standard adapter/header board combo (available as a Processor Extension Pak), which is then plugged into the target board (Figure 2-2).
Note: Older header boards used a 6-pin (RJ-11 type) modular connector instead
of an 8-pin connector, so these headers may be connected directly to the debugger.
For more on standard communication, see Section B.5.2 “Standard Communication”.
DS50002596A-page 18  2017 Microchip Technology Inc.
Operation
Target Board
Target Device
External Power supplied to either target or debugger.
Debugger
USB
Device with on-board ICE circuitry
Target Board
Transition Socket
Device-ICE
Processor Extension Pak
Standard
Adapter
Header
Device-ICE
ICD Header
OR
External Power supplied to either target or debugger.
USB
Debugger
USB
FIGURE 2-1: STANDARD DEBUGGER SYSTEM – DEVICE WITH ON-BOARD ICE CIRCUITRY
FIGURE 2-2: STANDARD DEBUGGER SYSTEM – ICE DEVICE
2017 Microchip Technology Inc. DS50002596A-page 19
MPLAB® ICD 4 User’s Guide
12345
6
Target
Connector
Target
Bottom Side
PC Board
VPP/MCLR
Vss
PGC
V
DD
PGD
Reserved
VDD
VPP/MCLR
PGC
PGD
V
SS
AVDD
AVSS
2
1
5
4
3
User Reset
50K
Interface
Connector
Application
PCB
Device

2.3 TARGET COMMUNICATION CONNECTIONS

2.3.1 Standard Communication Target Connection
Using the RJ-11 connector, the MPLAB ICD 4 In-Circuit Debugger is connected to 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 2-3.
Note: Cable connections on the debugger and target are mirror images of each
other, i.e., pin 1 on one end of the cable is connected to pin 6 on the other end of the cable. See Section B.5.3.3 “Modular Cable Specification”.
FIGURE 2-3: STANDARD CONNECTION AT TARGET
2.3.2 Target Connection Circuitry
Figure 2-4 shows the interconnections of the MPLAB ICD 4 In-Circuit Debugger to the
connector on the target board. The diagram also shows the wiring from the connector to a device on the target PCB. A pull-up resistor (usually around 50 k) connected from the V
PP/MCLR line to the VDD is recommended so that the line may be strobed low to
reset the device.
FIGURE 2-4: STANDARD CONNECTION TARGET CIRCUITRY
DS50002596A-page 20  2017 Microchip Technology Inc.
Operation
2.3.3 Target Power
There are two methods for externally powering the target:
Externally Powered through Target
Externally Powered through Debugger
In the following descriptions, only three lines are active and relevant to core debugger operation: pins 1 (V shown on Figure 2-4 for completeness.
When providing power to the target device, ensure that the target is not exposed to voltages higher than the device V
Absolute maximum ratings for the device V maximum rating conditions for any length of time may affect device reliability.
Functional operation of the device at conditions above the parameters indicated in the device data sheets specification is not recommended.
See the device data sheet for required device voltage levels and maximum ratings.
2.3.3.1 EXTERNALLY POWERED THROUGH TARGET
The recommended method for powering the target device is an external power supply connected directly to the target board. In this configuration, target V debugger to allow level translation for the target low-voltage operation. If the debugger does not sense voltage on its V operate.
PP/MCLR), 5 (PGC), and 4 (PGD). Pins 2 (VDD) and 3 (VSS) are
DD rating.
DD must not be exceeded. Exposure to the
DD is sensed by the
DD line (pin 2 of the interface connector), it will not
2.3.3.2 EXTERNALLY POWERED THROUGH DEBUGGER
An alternative method of powering the target device is an external power supply connected directly to the MPLAB ICD 4. Be aware that you must also select power from the MPLAB ICD 4 debugger via MPLAB X IDE.
Not all devices have the AV
DD and AVSS lines, but if they are present on the target
device, all must be connected to the appropriate levels in order for the debugger to operate. They cannot be left floating.
In general, it is recommended that all V the appropriate levels. Also, devices with a V
DD/AVDD and VSS/AVSS lines be connected to
CAP line (PIC18FXXJ MCUs, for example)
should be connected to the appropriate capacitor or level.
Note: The interconnection is very simple. Any problems experienced are often
caused by other connections or components on these critical lines that interfere with the operation of the MPLAB ICD 4 In-Circuit Debugger system, as discussed in the following section.
2017 Microchip Technology Inc. DS50002596A-page 21
MPLAB® ICD 4 User’s Guide
No!
No!
No!
No!
VPP/MCLR
PGC
PGD
1
5
4
Interface
Connector
2.3.4 Circuits That Will Prevent the Debugger From Functioning
Figure 2-5 shows the active debugger lines with some components that will prevent the
MPLAB ICD 4 In-Circuit Debugger system from functioning.
FIGURE 2-5: IMPROPER CIRCUIT COMPONENTS
In particular, these guidelines must be followed:
• Do not use pull-ups on PGC/PGD – they could disrupt the voltage levels.
• Do not use capacitors on PGC/PGD – they will prevent fast transitions on data and clock lines during programming and debugging communications, and slow programming times.
• Do not use capacitors on MCLR simple pull-up resistor is generally sufficient.
• Do not use diodes on PGC/PGD – they will prevent bidirectional communication between the debugger and the target device.
– they will prevent fast transitions of VPP. A

2.4 DEBUGGING

There are two steps to using the MPLAB ICD 4 In-Circuit Debugger system as a debugger. The first requires that an application is programmed into the target device (MPLAB ICD 4 can be used for this). The second uses the internal in-circuit debug hardware of the target Flash device to run and test the application program. These two steps are directly related to the MPLAB X IDE operations:
1. Programming the code into the target and activating special debug functions
(see the next section for details).
2. Using the debugger to set breakpoints and run.
For more information, refer to the MPLAB X IDE online Help.
If the target device cannot be programmed correctly, the MPLAB ICD 4 In-Circuit Debugger will not be able to debug it.
For programming, no clock is needed on the target device, but power must be supplied. When programming, the debugger puts programming levels on V clock pulses on PGC, and serial data via PGD. To verify that the part has been programmed correctly, clocks are sent to PGC and data is read back from PGD. This conforms to the ICSP protocol of the device under development. See the device programming specification for details.
DS50002596A-page 22  2017 Microchip Technology Inc.
PP/MCLR, sends

2.5 REQUIREMENTS FOR DEBUGGING

To debug (set breakpoints, see registers, etc.) with the MPLAB ICD 4 In-Circuit Debugger system, there are critical elements that must be working correctly:
• The debugger must be connected to a computer. It must be powered by the computer via the USB cable, and it must be communicating with the MPLAB X IDE software via the USB cable. See Section 3.3 “Debug Tutorial” for details.
• The target device must have power and a functional, running oscillator. If, for any reason, the target device does not run, the MPLAB ICD 4 In-Circuit Debugger will not be able to debug it.
• The target device must have its Configuration words programmed correctly. These are set using the MPLAB X IDE.
- The oscillator Configuration bits should correspond to RC, XT, etc., depending
on the target design.
- For some devices, the Watchdog Timer is enabled by default and needs to be
disabled.
- The target device must not have code protection enabled.
- The target device must not have table read protection enabled.
- For some devices with more than one PGC/PGD pair, the correct pair needs
to be configured. This only refers to debugging, since programming will work through any PGC/PGD pair.
When the conditions listed above are met, you may proceed to the following:
Sequence of Operations Leading to Debugging
Debugging Details
Operation
2.5.1 Sequence of Operations Leading to Debugging
Given that the Requirements for Debugging are met, these actions can be performed when the MPLAB ICD 4 In-Circuit Debugger is set as the current tool from the MPLAB X IDE menu (File>Project Properties
• When Debug>Debug Main Project programmed into the device’s memory via the ICSP protocol as described at the beginning of this section.
• A small “debug executive” program is loaded into the memory of the target device. Since some architectures require that 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 by MPLAB X IDE. These allow the debug executive to be activated by the debugger. For more information on the device’s reserved resources, see Section 2.7 “Resources Used
by the Debugger”.
• The target device is run in Debug mode.
):
is selected, the application code is
2017 Microchip Technology Inc. DS50002596A-page 23
MPLAB® ICD 4 User’s Guide
Program
Memory
File
Registers
Internal
Debug
Registers
VPP/MCLR
PGC
PGD
1
5
4
Executive
Debug
Area Used
Ta rg e t
be
Running
must
for Debug Executive to Function
Area
V
DD
Hardware Stack Shared by Debug
by Debug
Reserved for Debug
Executive
MPLAB ICD 4
In-Circuit Debugger
Executive
Executive
2.5.2 Debugging Details
Figure 2-6 illustrates the MPLAB ICD 4 In-Circuit Debugger system when it is ready to
begin debugging.
FIGURE 2-6: MPLAB
DEBUGGING
®
ICD 4 IN-CIRCUIT DEBUGGER READY TO BEGIN
To find out whether an application program will run correctly, a breakpoint is typically 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 Main Project
function is usually 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 (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, i.e., file register contents and the state of the CPU. These queries are performed by the debug executive.
The debug executive runs 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 (no oscillator, faulty power supply connection, shorts on the target board, etc.), then the debug executive cannot communicate to the MPLAB ICD 4 In-Circuit Debugger, and MPLAB X IDE will issue an error message.
DS50002596A-page 24  2017 Microchip Technology Inc.
Another way to set 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

Use the MPLAB ICD 4 as a programmer to program a non -ICE/-ICD device, i.e., a device not on a header board. Set the MPLAB ICD 4 In-Circuit Debugger as the current tool (File>Project Properties
• When Run>Run Main Project the device’s memory via the ICSP protocol. No clock is required while program­ming, and all modes of the processor can be programmed – including code pro­tect, Watchdog Timer enabled, and table read protect.
• A small “program executive” program may be loaded into the high area of program memory for some target devices. This increases programming speeds for devices with large memories.
• 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
Operation
) to perform these actions:
is selected, the application code is programmed into
line to Reset and start the target device.

2.7 RESOURCES USED BY THE DEBUGGER

For a complete list of resources used by the debugger for your device, see the online Help file in MPLAB X IDE for the MPLAB ICD 4 In-Circuit Debugger. From the MPLAB X IDE “Learn & Discover” page, click on Users Guide & Release Notes, then click on the link for the “Reserved Resources for MPLAB ICD 4.”
2017 Microchip Technology Inc. DS50002596A-page 25
MPLAB® ICD 4 User’s Guide
NOTES:
DS50002596A-page 26  2017 Microchip Technology Inc.

Chapter 3. Debugger Usage

3.1 INTRODUCTION

The following topics are discussed regarding how to install and use the MPLAB ICD 4 In-Circuit Debugger.
Installation and Setup
Debug Tutorial
Quick Debug/Program Reference
Debugger Limitations
Connecting the Target Board
Setting Up the Target Board
Starting and Stopping Debugging
Viewing Processor Memory and Files
Breakpoints and Stopwatch

3.2 INSTALLATION AND SETUP

Refer to the Help file “Getting Started with MPLAB X IDE” for details on installing the IDE and setting up the debugger to work with it.
In summary:
1. Install MPLAB X IDE (http://www.microchip.com/mplab/mplab-x-ide).
A tutorial is available in the MPLAB X IDE online Help that is accessible from the main menu bar Help>Tool Help Contents>MPLAB X IDE Help
2. Connect the MPLAB ICD 4 to the computer and allow the default USB drivers to
install. For more information on target connections, see Chapter 2. “Operation”.
MPLAB® ICD 4 USER’S GUIDE
.
Note: The debugger cannot power a target board. An external power supply
must be used. See Section 3.7.3 “Powering the Target Board”.
3. Select which language toolsuite/compiler you want to use for development and
install it on your computer.
4. Launch MPLAB X IDE.
5. Use the New Project wizard (File>New Project
6. Use the Project Properties dialog (File>Project Properties
7. Use the Project Properties dialog (File/Project Properties<Hardware Tool>
select the “ICD 4” tool and set up tool options for programming.
8. Run the project (build and run) from Run>Run Project
2017 Microchip Technology Inc. DS50002596A-page 27
) to create a new project.
) to set up options.
) to
.
MPLAB® ICD 4 User’s Guide
Items of note are:
1. Each debugger contains a unique identifier which, when first installed, will be recognized by the operating system, regardless of which computer USB port is used.
2. MPLAB X IDE operation connects to the hardware tool at runtime (Run or Debug Run). Configuration bits can only be viewed in the Configuration Bits window. To set them in code, select Window>PIC Memory Views tion Bits” from the Memory drop list, and select “Read/Write” from the Format drop list to enable access to the settings.

3.3 DEBUG TUTORIAL

Refer to the MPLAB X IDE Help file titled “Getting Started with MPLAB X IDE,” and navigate through the “Tutorial” to the “Running and Debugging Code.”

3.4 QUICK DEBUG/PROGRAM REFERENCE

The following table is a quick reference for using the MPLAB ICD 4 In-Circuit Debugger as either a debugging or programming tool.
TABLE 3-1: DEBUG VS. PROGRAM OPERATION
Item Debug Program
Needed Hardware A computer and target application (Microchip demo board or your own design)
Debugger, USB cable, and power supply
Device with on-board debug circuitry or debug header with special -ICE device
MPLAB X IDE selection
Program Operation Programs application code into the device.
Debug Features Available
Serial Quick-Time Programming (SQTP)
Command-line Operation
Project Properties, ICD 4 as Hardware Tool
Debug>Debug Main Project
Depending on the selections on the Project Properties dialog, this can be any range of program memory. In addition, a small debug executive is placed in program memory and other debug resources are reserved.
All for device – breakpoints, etc. N/A
N/A Use the MPLAB IPE to generate the
N/A Use IPECMD, found by default in:
Device (with or without on-board debug circuitry)
Program Target Project toolbar button
Programs application code into the device. Depending on the selections on the Project Properties dialog, this can be any range of program memory.
SQTP file.
C:\Program Files\Microchip\ MPLABX\<vx.xx>\mplab_ipe.
. Then, select “Configura-

3.5 DEBUGGER LIMITATIONS

For a complete list of debugger limitations for your device, see the online Help file in MPLAB X IDE for the MPLAB ICD 4 In-Circuit Debugger.
DS50002596A-page 28  2017 Microchip Technology Inc.

3.6 CONNECTING THE TARGET BOARD

Mini-B USB
3
From Power Supply*
Target Board
1
From Computer
Communications Cable
From Target
2
*Optionally, the Microchip power supply (AC002014)
From Power Supply
3
Mini-B USB
Ta rg e t Board
1
From Computer
Communications Cable
From Target
2
A connection is built in to select the type of communication with the target. See
Section 2.2 “Debugger to Target Communication” for more details and a diagram.
1. Connect the Mini-B USB cable between the debugger and the computer, if not
already connected.
2. Attach the communication cable(s) between debugger and target.
3. Connect power to target or debugger.
Note: In MPLAB X IDE, you can select the source from which to power the target.
In order to power the target from the MPLAB ICD 4 debugger, the power supply must be connected to the debugger.
FIGURE 3-1: POWERING TARGET DIRECTLY
Debugger Usage
FIGURE 3-2: POWERING TARGET THROUGH DEBUGGER
2017 Microchip Technology Inc. DS50002596A-page 29
MPLAB® ICD 4 User’s Guide

3.7 SETTING UP THE TARGET BOARD

The target must be set up for the type of target device to be used.
3.7.1 Using Production Devices
For production devices, the debugger may be connected directly to the target board. The device on the target board must have built-in debug circuitry in order to debug with the MPLAB ICD 4 In-Circuit Debugger. Consult the device data sheet to see whether the device has the necessary debug circuitry, i.e., it should have a “Background Debugger Enable” Configuration bit.
The target board must have a connector to accommodate the communications chosen for the debugger. For connection information, see Section 2.2 “Debugger to Target
Communication”.
3.7.2 Using ICE Devices
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. For more information on ICE headers, see the “Processor Extension Pak and Header Specification” (DS50001292).
A transition socket is used with the ICE header to connect the header to the target board. Transition sockets are available in various styles to allow a common header to be connected to one of the supported surface mount package styles. For more information on transition sockets, see the “Transition Socket Specification” (DS51194).
Header board layout will be different for headers or processor extension packs. For connection information, see Section 2.2 “Debugger to Target Communication”.
3.7.3 Powering the Target Board
There are two configurations for powering MPLAB ICD 4 and the target board:
• The target board is powered via an external power supply.
• The target board is powered through the MPLAB ICD 4, which is connected to an
external power supply.
An external power supply, Part Number AC002014, can be purchased from Microchip Direct (www.microchipdirect.com).
If you have not already done so, connect the MPLAB ICD 4 to the target board using the appropriate cables (see Section 3.6 “Connecting the Target Board”). Then, power the target board.
DS50002596A-page 30  2017 Microchip Technology Inc.
Loading...
+ 68 hidden pages