Microchip Technology PICkit 3 In-Circuit Debugger/Programmer User guide

PICkit 3
In-Circuit Debugger/Programmer
User’s Guide
For MPLAB® X IDE
2013 Microchip Technology Inc. DS52116A
Note the following details of the code protection feature on Microchip devices:
YSTEM
CERTIFIED BY DNV
== ISO/TS 16949 ==
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.
Trademarks
The Microchip name and logo, the Microchip logo, dsPIC, FlashFlex, K PICSTART, PIC and UNI/O are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor, MTP, SEEVAL and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A.
Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries.
Analog-for-the-Digital Age, Application Maestro, BodyCom, chipKIT, chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN, ECONOMONITOR, FanSense, HI-TIDE, In-Circuit Serial Programming, ICSP, Mindi, MiWi, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK, mTouch, Omniscient Code Generation, PICC, PICC-18, PICDEM, PICDEM.net, PICkit, PICtail, REAL ICE, rfLAB, Select Mode, SQI, Serial Quad I/O, Total Endurance, TSHARC, UniWinDriver, WiperLock, ZENA and Z-Scale 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.
GestIC and ULPP are registered trademarks of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in other countries.
All other trademarks mentioned herein are property of their respective companies.
© 2013, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.
Printed on recycled paper.
ISBN: 978-1-62077-008-5
EELOQ, KEELOQ logo, MPLAB, PIC, PICmicro,
32
logo, rfPIC, SST, SST Logo, SuperFlash
QUALITY MANAGEMENT S
DS52116A-page 2 2013 Microchip Technology Inc.
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
Object of Declaration: PICkit3 In-Circuit Debugger/Programmer
2013 Microchip Technology Inc. DS52116A-page 3
MPLAB® X PICkit™ 3 User’s Guide
NOTES:
DS52116A-page 4 2013 Microchip Technology Inc.
MPLAB® X PICkit™ 3 USER’S GUIDE

Table of Contents

Preface ........................................................................................................................... 7
Getting Started
Chapter 1. About the In-Circuit Debugger/Programmer
1.1 Introduction ................................................................................................... 13
1.2 PICkit 3 In-Circuit Debugger/Programmer Defined ...................................... 13
1.3 How the PICkit 3 In-Circuit Debugger/Programmer Helps You .................... 16
1.4 PICkit 3 In-Circuit Debugger/Programmer Components .............................. 16
Chapter 2. Operation
2.1 Introduction ................................................................................................... 17
2.2 Tools Comparison ........................................................................................ 18
2.3 PICkit 3 vs. PICkit 2 ...................................................................................... 18
2.4 Debugger to Target Communication ............................................................ 19
2.5 Communication Connections ....................................................................... 21
2.6 Debugging .................................................................................................... 24
2.7 Requirements for Debugging ....................................................................... 25
2.8 Programming ................................................................................................ 27
2.9 Resources Used by the Debugger ............................................................... 27
Chapter 3. Debugger Usage
3.1 Introduction ................................................................................................... 29
3.2 Installation and Setup ................................................................................... 29
3.3 Common Debug Features ............................................................................ 30
3.4 Connecting the Target .................................................................................. 30
3.5 Setting Up the Target Board ......................................................................... 31
3.6 Setting Up MPLAB X IDE ............................................................................. 33
3.7 Starting and Stopping Debugging ................................................................ 33
3.8 Viewing Processor Memory and Files .......................................................... 33
Chapter 4. PICkit 3 Debug Express
4.1 Introduction ................................................................................................... 35
4.2 PICkit 3 Debug Express Kit Contents ........................................................... 35
4.3 Installing the Hardware and Software .......................................................... 35
2013 Microchip Technology Inc. DS52116A-page 5
MPLAB® X PICkit™ 3 User’s Guide
Chapter 5. PICkit 3 Programmer-To-Go
5.1 Introduction ................................................................................................... 37
5.2 USB Power for PICkit 3 Programmer-To-Go ................................................ 37
5.3 PICkit 3 Programmer-To-Go Supported Devices ......................................... 38
5.4 Setting up PICkit 3 for Programmer-To-Go Operation ................................. 39
5.5 Using PICkit 3 Programmer-To-Go .............................................................. 42
5.6 Exiting Programmer-To-Go Mode ................................................................ 43
Troubleshooting
Chapter 6. Troubleshooting First Steps
6.1 Introduction ................................................................................................... 47
6.2 The 5 Questions to Answer First .................................................................. 47
6.3 Top 10 Reasons Why You Can’t Debug ...................................................... 47
6.4 Other Things to Consider ............................................................................. 48
Chapter 7. Frequently Asked Questions (FAQs)
7.1 Introduction ................................................................................................... 49
7.2 How Does It Work ........................................................................................ 49
7.3 What’s Wrong ............................................................................................... 50
Chapter 8. Error Messages
8.1 Introduction ................................................................................................... 53
8.2 Specific Error Messages .............................................................................. 53
8.3 General Corrective Actions .......................................................................... 54
Chapter 9. Engineering Technical Notes (ETNs)
Reference
Appendix A. Hardware Specification
A.1 Introduction .................................................................................................. 61
A.2 Highlights ..................................................................................................... 61
A.3 Declaration of Conformity ............................................................................ 61
A.4 USB Port/Power ........................................................................................... 62
A.5 PICkit 3 In-Circuit Debugger/Programmer ................................................... 62
A.6 Standard Communication Hardware ............................................................ 63
A.7 Target Board Considerations ....................................................................... 65
Appendix B. PICkit 3 Schematics
Appendix C. Revision History
Glossary .......................................................................................................................71
Index .............................................................................................................................91
Worldwide Sales and Service......................................................................................94
DS52116A-page 6 2013 Microchip Technology Inc.
MPLAB® X PICkit™ 3 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 “DSXXXXXA”, where “XXXXX” 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 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 PICkit 3™ starter kit. Items discussed in this chapter include:
• Document Layout
• Conventions Used in this Guide
• Recommended Reading
®
X IDE online help.
2013 Microchip Technology Inc. DS52116A-page 7
MPLAB® X PICkit™ 3 User’s Guide

DOCUMENT LAYOUT

This document describes how to use the PICkit 3 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 In-Circuit Debugger/Programmer
Describes the PICkit 3, and how it can help you develop your application.
Chapter 2. Operation
Presents the theory of PICkit 3 operation. Explains configuration options.
Chapter 3. Debugger Usage
Discusses installation and set up, common debug features, using targets, setting up MPLAB topics.
Chapter 4. PICkit 3 Debug Express
Provides basic information about using the PICkit 3 Debug Express.
Chapter 5. PICkit 3 Programmer-To-Go
Provides instructions for using the PICkit 3 unit to program a device even though it is not connected to a personal computer (PC).
®
Integrated Development Environment (IDE), and related debugger
Part 2 Troubleshooting
Chapter 6. Troubleshooting First Steps – The first things you should try if you
are having issues with debugger operation.
Chapter 7. Frequently Asked Questions (FAQs) – A list of frequently asked
questions, useful for troubleshooting.
Chapter 8. Error Messages – A list of error messages and suggested
resolutions.
Chapter 9. Engineering Technical Notes (ETNs)
Part 3 Reference
Appendix A. Hardware Specification – The hardware and electrical
specifications of the debugger system.
Appendix B. PICkit 3 Schematics
Appendix C. Revision History
DS52116A-page 8 2013 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
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
®
IDE User’s Guide
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)
{ ...
}
2013 Microchip Technology Inc. DS52116A-page 9
MPLAB® X PICkit™ 3 User’s Guide

RECOMMENDED READING

This user's guide describes how to use PICkit 3. 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 PICkit with your target design.
Release Notes for PICkit 3
For the latest information on using PICkit 3, read the release notes under “Release Notes and Support Documentation” on the Start Page. The release notes contain update information and known issues that may not be included in this user’s guide.
MPLAB X - Using PICkit 3 In-Circuit Debugger Poster (DS52010)
This poster shows you how to hook up the hardware and install the software for the PICkit 3 programmer Debugger using standard communications and a target board.
PICkit 3 In-Circuit Debugger/Programmer Online Help File
A comprehensive help file for the debugger is included with MPLAB X IDE. Usage, troubleshooting and hardware specifications are covered. This may be more up-to-date than the printed documentation. Also, limitations are listed for various devices.
Processor Extension Pak and Header Specification (DS51292)
This booklet describes how to install and use PICkit in-circuit debug headers 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.
DS52116A-page 10 2013 Microchip Technology Inc.
MPLAB® X PICkit™ 3 USER’S GUIDE

Part 1 – Getting Started

Chapter 1. About the In-Circuit Debugger/Programmer........................................... 13
Chapter 2. Operation.................................................................................................... 17
Chapter 3. Debugger Usage........................................................................................ 29
Chapter 4. PICkit 3 Debug Express ............................................................................ 35
Chapter 5. PICkit 3 Programmer-To-Go...................................................................... 37
2013 Microchip Technology Inc. DS52116A-page 11
MPLAB® X PICkit™ 3 User’s Guide
NOTES:
DS52116A-page 12 2013 Microchip Technology Inc.
MPLAB® X PICkit™ 3 USER’S GUIDE

Chapter 1. About the In-Circuit Debugger/Programmer

1.1 INTRODUCTION

An overview of the PICkit 3™ In-Circuit Debugger/Programmer system is provided.
• PICkit 3 In-Circuit Debugger/Programmer Defined
• How the PICkit 3 In-Circuit Debugger/Programmer Helps You
• PICkit 3 In-Circuit Debugger/Programmer Components

1.2 PICKIT 3 IN-CIRCUIT DEBUGGER/PROGRAMMER DEFINED

The PICkit 3 In-Circuit Debugger/Programmer (see Figure 1-1) is a simple, low-cost in-circuit debugger that is controlled by a PC running MPLAB X IDE software on a Windows of the development engineer’s tool suite. The application usage can vary from software development to hardware integration.
The PICkit 3 In-Circuit Debugger/Programmer is a debugger system used for hardware and software development with Microchip PIC Digital Signal Controllers (DSCs) that are based on In-Circuit Serial Programming™ (ICSP™) and Enhanced In-Circuit Serial Programming 2-wire serial interfaces.
In addition to debugger functions, the PICkit 3 In-Circuit Debugger/Programmer system also may be used as a development programmer.
®
platform. The PICkit 3 In-Circuit Debugger/Programmer is an integral part
®
microcontrollers (MCUs) and dsPIC®
Note: The PICkit 3 In-Circuit Debugger/Programmer is NOT a production
programmer. It should be used for development purposes only.
The PICkit 3 debugger was developed for programming and debugging embedded processors with debug functions. The PICkit 3 features include:
• Full-speed USB support using Windows standard drivers
• Real-time execution
• Processors running at maximum speeds
• Built-in over-voltage/short circuit monitor
• Low voltage to 5V (1.8-5V range)
• Diagnostic LEDs (power, active, status)
• Read/write program and data memory of microcontroller
• Erasing of all memory types (EEPROM, ID, configuration and program) with verification
• Peripheral freeze at breakpoint
2013 Microchip Technology Inc. DS52116A-page 13
MPLAB® X PICkit™ 3 User’s Guide
6
2
1
3
4
Legend:
1 – Lanyard Loop
2 – USB Port Connection
3 – Pin 1 Marker
4 – Programming Connector
5 – Indicator LEDs
6 – Push Button
5
FIGURE 1-1: PICkit™ 3 MCU IN-CIRCUIT DEBUGGER/PROGRAMMER
1.2.1 Lanyard Loop
The lanyard loop provides a point of attachment so that the PICkit 3 can be suspended or worn.
1.2.2 USB Port Connection
The USB port connection is a USB mini-B connector. Connect the PICkit 3 to the PC using the supplied USB cable.
1.2.3 Pin 1 Marker
This marker designates the location of pin 1 for proper connector alignment.
DS52116A-page 14 2013 Microchip Technology Inc.
About the In-Circuit Debugger/Programmer
1 2 3 4 5 6
* The 6-pin header (0.100" spacing) accepts 0.025" square pins.
Pin Description*
1 = MCLR/
VPP
2 = VDD Target
3 = V
SS (ground)
4 = PGD (ICSPDAT)
5 = PGC (ICSPCLK)
6 = PGM (LVP)
Pin 1 Indicator
1.2.4 Programming Connector
The programming connector is a 6-pin header (0.100" spacing) that connects to the target device. See the pinout specification in Figure 1-2.
FIGURE 1-2: PICkit™ 3 PROGRAMMER CONNECTOR PINOUT
Note: Programming Serial EEPROMS devices requires a different programming
connector pinout. Pinouts for those types of devices are available in the ReadMe file for the PICkit 3 included with the MPLAB X IDE software (MPLAB X IDE Start Page, click on Release Notes and Support Documen- tation).
1.2.5 Indicator LEDs
The indicator LEDs indicate the status of operations on the PICkit 3.
1. Power (green) – power is supplied to the PICkit 3 via the USB port
2. Active (blue) – connected to the PC USB port and the communication link is
active
3. Status (one of three colors)
Success (green) – ready to start, or successful completion
Busy (orange) – busy with a function in progress, e.g., programming
Error (red) – an error has occurred
Note: Blinking LEDs indicate additional information. For details, see Table 5-2.
1.2.6 Push Button
The push button is used for Programmer-To-Go operations. See Chapter 5. “PICkit 3 Programmer-To-Go”.
2013 Microchip Technology Inc. DS52116A-page 15
MPLAB® X PICkit™ 3 User’s Guide
PICkit 3
To Target Board
USB Cable to PC
Indicator Lights

1.3 HOW THE PICKIT 3 IN-CIRCUIT DEBUGGER/PROGRAMMER HELPS YOU

The PICkit 3 In-Circuit Debugger/Programmer enables you to:
• debug your application on your own hardware in real time
• debug with hardware breakpoints
• set breakpoints based on internal events
• monitor internal file registers
• emulate at full speed
• program your device

1.4 PICKIT 3 IN-CIRCUIT DEBUGGER/PROGRAMMER COMPONENTS

The PICkit 3 In-Circuit Debugger/Programmer system contains the following components:
1. the PICkit 3 with indicator lights for power, activity and status.
2. a USB cable to provide communication between the debugger and a PC, and to provide power to the debugger.
FIGURE 1-3: BASIC DEBUGGER SYSTEM
DS52116A-page 16 2013 Microchip Technology Inc.
Additional items can be ordered separately:
• PICkit 3 Debug Express Kit, which includes:
- 44-pin demo board with a PIC18F45K20 MCU
- free version of MPLAB C Compiler for PIC18 MCUs
- easy-to-understand lessons and tutorials
- other software utilities, examples with source code and full documentation
• Transition socket
• ICD headers
• MPLAB X IDE processor extension kits

2.1 INTRODUCTION

A simplified description of how the PICkit 3 In-Circuit Debugger/Programmer system works is provided here. It is intended to provide enough information so 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 described so that problems, if encountered, are quickly resolved.
• Tools Comparison
• PICkit 3 vs. PICkit 2
• Debugger to Target Communication
• Communication Connections
• Debugging
• Requirements for Debugging
• Programming
• Resources Used by the Debugger
MPLAB® X PICkit™ 3 USER’S GUIDE

Chapter 2. Operation

2013 Microchip Technology Inc. DS52116A-page 17
MPLAB® X PICkit™ 3 User’s Guide

2.2 TOOLS COMPARISON

The PICkit 3 In-Circuit Debugger/Programmer system differs physically and operation­ally from other Microchip debug tools as shown below. Specific features may vary by device (see the online help file, “Device and Feature Support”.)
TABLE 2-1: DEBUG TOOLS COMPARISON
PICkit 3
Features
USB Speed Full Only High and Full High and Full
USB Driver HID Microchip Microchip
USB Powered Yes Yes Yes
Power to Target Yes Yes No
Programmable V
Vdd Drain from Target 20 ma <1 ma <1 ma
Overvoltage/Overcurrent Protection
Device emulation Full speed Full speed Full speed
HW Breakpoints Simple Complex Complex
Stopwatch Yes Yes Yes
SW Breakpoints No Yes Yes
Program Image 512K bytes No No
Serialized USB Yes Yes Yes
Trace No No Yes
Data Capture No No Yes
Logic Probe Triggers No No Yes
High Speed/LVDS Connection
Production Programmer No Yes Yes
PP and VDD Yes Yes Yes
Programmer/
Debugger
Yes (SW) Yes (HW) Yes (HW)
No No Yes
MPLAB ICD 3
In-Circuit
Debugger
MPLAB REAL ICE
In-Circuit Emulator

2.3 PICkit 3 vs. PICkit 2

The PICkit 3 In-Circuit Debugger/Programmer system is similar in function to the PICkit 2 In-Circuit Debugger system.
Similarities of the two debuggers include:
• Powered via USB cable to PC
• Provides a programmable voltage power supply
The PICkit 3 differs from the PICkit 2 by providing these additional features:
• Extended EE program image space (512 Kbytes)
• True voltage reference
• Increased voltage range (1.8-5V V
DS52116A-page 18 2013 Microchip Technology Inc.
DD; 1.8-14V VPP)

2.4 DEBUGGER TO TARGET COMMUNICATION

Target Device
or PIM
Power
PICkit 3
Mini-USB
to PC
cable
Tar ge t Board
The debugger system configurations are discussed in the following sections.
CAUTION
Install the software before making any hardware connections, i.e., do NOT connect the hardware before installing the software and USB drivers.
Do NOT change hardware connections when the PICkit 3 and/or the target are powered.
Standard ICSP Device Communication
The debugger system can be configured to use standard ICSP communication for both programming and debugging functions. This 6-pin connection is the same one used by the older PICkit 2 Development Programmer/Debugger.
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 Pak), which is
then plugged into the target board (Figure 2-2).
Operation
Note: Older header boards used a 6-pin modular connector instead of an 6-pin
single in-line connector, so these headers can be connected to the debugger using an AC164110 ICSP adapter.
For more on standard communication, see Appendix A. “Hardware Specification”.
FIGURE 2-1: STANDARD DEBUGGER SYSTEM – DEVICE WITH
ON-BOARD ICE CIRCUITRY
2013 Microchip Technology Inc. DS52116A-page 19
MPLAB® X PICkit™ 3 User’s Guide
Target Board
Transition Socket
Device-ICE
AC164110
Adapter
Header
Power
PICkit 3
Mini-USB
to PC
cable
FIGURE 2-2: STANDARD DEBUGGER SYSTEM – ICE DEVICE
DS52116A-page 20 2013 Microchip Technology Inc.

2.5 COMMUNICATION CONNECTIONS

12345
6
Target
Connector
Target
Bottom Side
PC Board
VPP/MCLR
Vss
PGC
V
DD
PGD
LVP
2.5.1 Standard Communication Target Connections
2.5.1.1 USING SINGLE IN-LINE CONNECTOR
Use the 6-pin in-line connector between the PICkit 3 In-Circuit Debugger/Programmer and the target board connector. See Figure 2-1. Also see Table 2-2 and
Section A.6 “Standard Communication Hardware”.
TABLE 2-2: TARGET CONNECTOR PINOUT
Connector Pin Microcontroller Pin
1MCLR/VPP
2VDD
3 Ground
4 PDG (ICSPDAT)
5 PGC (ICSPCLK)
6 PGM (LVP)
2.5.1.2 USING AN ADAPTER
Use the AC164110 adapter between the PICkit 3 In-Circuit Debugger/Programmer 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 PC board in Figure 2-3.
Operation
Note: Cable connections at 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 A.6.2.3 “Modular Cable Specification”.
FIGURE 2-3: STANDARD RJ-11 CONNECTION AT TARGET
2013 Microchip Technology Inc. DS52116A-page 21
MPLAB® X PICkit™ 3 User’s Guide
VDD
VPP/MCLR
PGC
PGD
V
SS
AVDD
AVSS
2
1
5
4
3
4.7K-10K
Interface
Connector
Application
PC Board
Device
2.5.2 Target Connection Circuitry
Figure 2-4 shows the interconnections of the PICkit 3 In-Circuit Debugger/Programmer to the connector on the target board. The diagram also shows the wiring from the connector to a device on the target PC board. A pull-up resistor (typically around 10 k) is recommended to be connected from the V be strobed low to reset the device.
FIGURE 2-4: STANDARD CONNECTION TARGET CIRCUITRY
PP/MCLR line to VDD so that the line may
2.5.3 Target Powered
In the following descriptions, only three lines are active and relevant to core debugger operation: pins 1 (V
PP/MCLR), 5 (PGC) and 4 (PGD). Pins 2 (VDD) and 3 (VSS) are
shown on Figure 2-4 for completeness. PICkit 3 has two configurations for powering the target device: internal debugger and external target power.
The recommended source of power is external and derived from the target application. In this configuration, target V the target low-voltage operation. If the debugger does not sense voltage on its V
DD is sensed by the debugger to allow level translation for
DD line
(pin 2 of the interface connector), it will not operate.
2.5.4 Debugger Powered
The internal debugger power is limited to 30 mA. This can be helpful with very small applications that have the device V for independent programming. However, is not recommended for general usage because imposes more current demands from the USB power system derived from the PC.
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.
Also, devices with a V to the appropriate capacitor or level.
Note: The interconnection is very simple. Any problems that occur are often
caused by other connections or components on these critical lines that interfere with the operation of the PICkit 3 In-Circuit Debugger/Programmer.
CAP line (PIC18FXXJ MCUs, for example) should be connected
DD separated from the rest of the application circuit
DS52116A-page 22 2013 Microchip Technology Inc.
Operation
No!
No!
No!
No!
VPP/MCLR
PGC
PGD
1
5
4
Interface
Connector
2.5.5 Circuits That Will Prevent the Debugger From Functioning
Figure 2-5 shows the active debugger lines with some components that will prevent the PICkit 3 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 will disrupt the voltage levels, since
these lines have 4.7 k pull-down resistors in the debugger.
• Do not use capacitors on PGC/PGD – they will prevent fast transitions on data
and clock lines during programming and debug communications.
• Do not use capacitors on MCLR
– they will prevent fast transitions of VPP. A
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.
2013 Microchip Technology Inc. DS52116A-page 23
MPLAB® X PICkit™ 3 User’s Guide
+5V
Programming
4.7 k
4.7 k
VPP/MCLR
PGC
PGD
1
5
4
Internal Circuits
VSS
VDD
Vol ta ge

2.6 DEBUGGING

There are two steps to using the PICkit 3 In-Circuit Debugger/Programmer system as a debugger. The first step requires that an application be programmed into the target device (usually with the PICkit 3 itself). The second step 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.
If the target device cannot be programmed correctly, the PICkit 3 In-Circuit Debugger/Programmer will not be able to debug.
Figure 2-6 shows the basic interconnections required for programming. Note that this is the same as Figure 2-4, but for the sake of clarity, the V debugger are not shown.
FIGURE 2-6: PROPER CONNECTIONS FOR PROGRAMMING
DD and VSS lines from the
A simplified diagram of some of the internal interface circuitry of the PICkit 3 In-Circuit Debugger/Programmer is shown. For programming, no clock is needed on the target device, but power must be supplied. When programming, the debugger puts programming levels on V
PP/MCLR, sends 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.
DS52116A-page 24 2013 Microchip Technology Inc.

2.7 REQUIREMENTS FOR DEBUGGING

To debug (set breakpoints, see registers, etc.) with the PICkit 3 In-Circuit Debugger/Programmer system, there are critical elements that must be working correctly:
• The debugger must be connected to a PC. It must be powered by the PC via the
USB cable, and it must be communicating with the MPLAB X IDE software via the USB cable. See Chapter 3. “Debugger Usage” for details.
• The debugger must be connected as shown in Figure 2-6 to the V
PGD pins of the target device with the modular interface cable (or equivalent). V
SS and VDD are also required to be connected between the debugger and target
device.
• The target device must have power and a functional, running oscillator. If the
target device does not run, for any reason, the PICkit 3 In-Circuit Debugger/Programmer cannot debug.
• The target device must have its Configuration words programmed correctly:
- The oscillator Configuration bits should correspond to RC, XT, etc., depending upon 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.
• PGM (LVP) should be disabled.
When the conditions listed above are met, you may proceed to the following:
• Sequence of Operations Leading to Debugging
• Debugging Details
Operation
PP, PGC and
2.7.1 Sequence of Operations Leading to Debugging
Given that the Requirements for Debugging are met, these actions can be performed when the PICkit 3 In-Circuit Debugger/Programmer is set as the current tool from the MPLAB X IDE menu (Edit>Project Properties, Advanced, MPLAB Environment
• When Debug>Debug Project 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 high area of program memory on the target device. 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 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.9 “Resources Used by the Debugger”.
• The target device is run in Debug mode.
is selected, the application code is programmed into
):
2013 Microchip Technology Inc. DS52116A-page 25
MPLAB® X PICkit™ 3 User’s Guide
+5V
+12V
4.7 k
4.7 k
Internal Circuits
Program
Memory
File
Registers
Internal
Debug
Registers
VPP/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
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 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
function is selected in MPLAB X IDE. The debugger
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.
DS52116A-page 26 2013 Microchip Technology Inc.
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.8 PROGRAMMING

There are three ways to program a device with the PICkit 3 unit:
• Through MPLAB X IDE with the PICkit 3 connected to the PC.
• Through PICkit 3 Programmer-To-Go, after setting it up through MPLAB X IDE. (See Chapter 5. “PICkit 3 Programmer-To-Go” for more information.)
• Through PICkit 3 Programmer Application, a software program that allows you to program devices with PICkit 3 without using MPLAB X IDE. (See “PICkit 3 Programmer Application User’s Guide” for instructions.)
Use the PICkit 3 as a programmer to program an actual (non -ICE/-ICD) device, i.e., a device not on a header board. Set the PICkit 3 as the current tool (Edit>Project Properties, Advanced, MPLAB Environment) to perform these actions:
• When Run>Run Project 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.
• A small “program executive” program may be loaded into the high area of program memory for some target device. 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
The PICkit 3 In-Circuit Debugger/Programmer system programs the target using ICSP.
PP, PGC and PGD lines should be connected as described previously. No clock is
V required while programming, and all modes of the processor can be programmed, including code protection, Watchdog Timer, and table read protection.
Operation
is selected, the application code is programmed into the
line to Reset and start the target.

2.9 RESOURCES USED BY THE DEBUGGER

For a complete list of resources used by the debugger for your device, please see MPLAB X IDE Start Page, click on Release Notes and Support Documentation, then click on link for the Reserved Resources for PICkit 3.
2013 Microchip Technology Inc. DS52116A-page 27
MPLAB® X PICkit™ 3 User’s Guide
NOTES:
DS52116A-page 28 2013 Microchip Technology Inc.
MPLAB® X PICkit™ 3 USER’S GUIDE

Chapter 3. Debugger Usage

3.1 INTRODUCTION

The following topics regarding how to install and use the PICkit 3 In-Circuit Debugger/Programmer system are discussed here.
• Installation and Setup
• Common Debug Features
• Connecting the Target
• Setting Up the Target Board
• Setting Up MPLAB X IDE
• Starting and Stopping Debugging
• Viewing Processor Memory and Files
• For more on the Editor, see NetBeans Help, IDE Basics>Basic File Features.

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.
2. Connect the PICkit 3 to the PC and allow the default drivers to install. For more
information on target connections, see Chapter 2. “Operation”.
Note: The debugger can power a target board only up to 100 mA.
3. Install the language toolsuite/compiler you want to use for development.
4. Launch MPLAB X IDE.
5. Use the New Project wizard (File>New Project
project.
6. Use the project Properties dialog (File>Project Properties
7. Use the project Properties dialog (File>Project Properties<Hardware tool>
up tool options for programming.
8. Run the project (build and run) from Run>Run Project
Items of note are:
1. Each debugger contains a unique identifier which, when first installed, will be
recognized by the OS, regardless of which computer USB port is used.
2. MPLAB X IDE operation connects to the hardware tool at runtime (Run or Debug
Run). To always be connected to the hardware tool (like MPLAB IDE v8), see
Tools>Options
connected” checkbox.
3. Configuration bits can only be viewed in the Configuration Bits window. To set
them in code, select W Bits” from the Memory drop list, and select “Read/Write” from the Format drop list to enable access to the settings.
, Embedded button, Generic Settings tab, “Keep hardware tool
indow>PIC Memory Views. Then, select “Configuration
) to add your “PICkit 3” to your
) to set up options.
) to set
.
2013 Microchip Technology Inc. DS52116A-page 29
Loading...
+ 65 hidden pages