PICkit 3 User's Guide
PICkit 3 User's Guide
Programmer/Debugger
User’s Guide
• 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.
ISBN: 978-1-60932-373-8
Microchip received ISO/TS-16949:2002 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® MCUs and dsPIC® DSCs, KEELOQ® code hopping
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.
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® IDE online 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
PICkit™ 3 programmer/debugger. Items discussed include:
• Document Layout
• Conventions Used in this Guide
• Warranty Registration
• Recommended Reading
• The Microchip Web Site
• Development Systems Customer Change Notification Service
• Customer Support
• Revision History
DOCUMENT LAYOUT
This document describes how to use the PICkit 3 as a development tool to emulate and
debug firmware on a target board. The manual layout is as follows:
• Chapter 1. Overview – An overview of the PICkit 3 programmer/debugger.
• Chapter 2. Theory of Operation – A simplified description of how the PICkit 3
programmer/debugger works.
• Chapter 3. Installation – How to install the PICkit 3 programmer/debugger.
• Chapter 4. General Setup – Provides Instructions on how to get started using the
PICkit 3 programmer/debugger to program supported devices.
• Chapter 5. PICkit 3 Debug Express – Provides basic information on using the
PICkit™ 3 Debug Express.
• Chapter 6. PICkit 3 Programmer-To-Go – Provides instruction on using the
PICkit 3 unit to program devices without being connected to a PC.
• Chapter 7. Troubleshooting First Steps – Begins the troubleshooting process
by identifying first steps and common reasons for problems with debugging.
• Chapter 8. Frequently Asked Questions (FAQs) – Provides information on
solving common problems.
• Chapter 9. Error Messages – Provides specific error messages and general
corrective actions.
• Chapter 10. Debugger Function Summary – Summarizes the available
debugging functions.
• Appendix A. Hardware Specification – Details hardware and electrical
specifications for the PICkit 3.
• Appendix B. PICkit 3 Schematics – Provides hardware schematic diagrams for
the PICkit 3 programmer/debugger.
DOCUMENTATION CONVENTIONS
Description Represents Examples
Arial font:
Italic Referenced books MPLAB® IDE User’s Guide
Emphasized text ...is the only compiler...
Initial caps A window the Output window
A dialog the Settings dialog
A menu selection select Enable Programmer
Quotes A field name in a window or “Save project before build”
dialog
Underlined, italic with right A menu path File>Save
angle bracket
Bold characters A dialog button Click OK
A tab Click the Power tab
Text in angle brackets < > A key on the keyboard Press <Enter>, <F1>
Courier New font:
Plain Sample source code #define START
Filenames autoexec.bat
File paths c:\mcc18\h
Keywords _asm, _endasm, static
Command-line options -Opa+, -Opa-
Bit values 0, 1
Constants 0xFF,’A’
Italic A variable argument file.o, where file can be
any valid filename
Square brackets [ ] Optional arguments mpasmwin [options]
file [options]
Curly brackets and pipe Choice of mutually exclusive errorlevel {0|1}
character: { | } arguments; an OR selection
Ellipses... Replaces repeated text var_name [,
var_name...]
Represents code supplied by void main (void)
user { ...
}
WARRANTY REGISTRATION
Please complete the enclosed Warranty Registration Card and mail it promptly.
Sending in the Warranty Registration Card entitles users to receive new product
updates. Interim software releases are available at the Microchip web site.
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.
CUSTOMER SUPPORT
Users of Microchip products can receive assistance through several channels:
• Distributor or Representative
• Local Sales Office
• Field Application Engineer (FAE)
• Technical Support
Customers should contact their distributor, representative or field application engineer
(FAE) for support. Local sales offices are also available to help customers. A listing of
sales offices and locations is included in the back of this document. See our web site
for a complete, up-to-date listing of sales offices.
Technical support is available through the web site at: http://support.microchip.com.
Documentation errors or comments may be e-mailed to [email protected].
REVISION HISTORY
Revision A (January 2009)
This is the initial release of this document.
1 2
Legend:
1 – Lanyard Connection
2 – USB Port Connection
3 – Pin 1 Marker
4 – Programming Connector
5 – Status LEDs
6 – Push Button
6
Pin 1 Indicator
Pin Description*
1 1 = MCLR/VPP
2
2 = VDD Target
3
4 3 = VSS (ground)
5
6 4 = PGD (ICSPDAT)
5 = PGC (ICSPCLK)
6 = PGM (LVP)
Note: The programming connector pin functions are different for programming
Serial EEPROM devices. See the ReadMe file for the PICkit 3
(Help>Readme) included with the MPLAB IDE software for these pinouts.
Indicator
Lights
PICkit™ 3
USB Cable to PC
To Target Board
CAUTION
Do not change hardware connections while the PICkit 3 or target is powered.
Note: Older header boards used a 6-pin (RJ-11) connector instead of an 8-pin
connector, so these headers may be connected to the debugger with the
AC164110 ICSP adapter.
PICkit™ 3
Target Device
or PIM
Mini-USB
cable
to PC
Target Board
Power
AC164110
Adapter
Mini-USB
cable
to PC
PICkit™ 3
Device-ICE
Power
Header
1 MCLR/VPP
2 VDD
3 Ground
4 PGD (ICSPDAT)
5 PGC (ICSPCLK)
6 PGM (LVP)
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”.
Target
Connector
PGD
2 4 6 LVP
VDD
PGC
1 3 5 Target
VPP/MCLR
Vss PC Board
Bottom Side
VDD 2
Device 4.7K-10K
VPP/MCLR 1
PGC 5
PGD 4
VSS 3
AVDD
AVSS Interface
Connector
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 PICkit 3 programmer/debugger, as
discussed in the following section.
VPP/MCLR 1
No!
No!
No!
PGC 5
4
PGD
Interface
No! Connector
2.5 DEBUGGING
There are two steps to using the PICkit 3 programmer/debugger system as a debugger.
The first requires that an application be programmed into the target device (usually with
the PICkit 3 itself). 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 IDE operations:
1. Program the code into the target and activate special debug functions (see the
next section for details).
2. Use the debugger to set breakpoints and run.
If the target device cannot be programmed correctly, the PICkit 3
programmer/debugger 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 VDD and VSS lines from the
debugger are not shown.
Programming VDD
Voltage
+5V 1
VPP/MCLR
Internal Circuits
4.7 k 5
PGC
4
PGD
4.7 k
VSS
Internal Target
VDD must
Debug be
Registers Running
+12V for Debug
1 Executive
+5V VPP/MCLR
Debug to Function
Internal Circuits
Executive
4.7 k Area
PGC Reserved
for Debug
5 Executive
4.7 k Program
Memory
4
PGD
Hardware
Stack Shared
by Debug Exec
Area Used by
Debug Exec File
Registers
Typically, in order to find out if an application program will run correctly, a breakpoint is
set early in the program code. When a breakpoint is set from the user interface of
MPLAB IDE, the address of the breakpoint is stored in the special internal debug
registers of the target device. Commands on PGC and PGD communicate directly to
these registers to set the breakpoint address.
Next, the Debugger>Run function or the Run icon (forward arrow) is usually pressed
from MPLAB IDE. The debugger will then tell the debug executive to run. The target
will start from the Reset vector and execute until the Program Counter reaches the
breakpoint address previously stored in the internal debug registers.
After the instruction at the breakpoint address is executed, the in-circuit debug
mechanism of the target device “fires” and transfers the device’s Program Counter to
the debug executive (much like an interrupt) and the user’s application is effectively
2.7 PROGRAMMING
There are three ways to program a device with the PICkit 3 unit:
• Through MPLAB IDE with the PICkit 3 connected to the PC.
• Through PICkit 3 Programmer-To-Go, after setting it up through MPLAB IDE. (See
Chapter 6. “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 IDE. (See “PICkit™ 3
Programmer Application User’s Guide” for instructions.)
Use the PICkit 3 programmer/debugger as a programmer to program an actual (non
-ICE/-ICD) device, i.e., a device not on a header board. From the MPLAB IDE menu,
select “PICkit 3” from Programmer>Select Programmer and compile/assemble your
application code with the “Build Configuration” list box on the MPLAB IDE toolbar set
to “Release”. Also, it may be set by selecting Project>Build Configuration>Release.
All debug features are turned off or removed when the debugger is used as a
programmer. When using the Programmer>Program selection to program a device,
MPLAB IDE will disable the in-circuit debug registers so the PICkit 3
programmer/debugger will program only the target application code and the
Configuration bits (and EEPROM data, if available and selected) into the target device.
The debug executive will not be loaded. As a programmer, the debugger can only
toggle the MCLR line to reset and start the target. A breakpoint cannot be set, and
register contents cannot be seen or altered.
The PICkit 3 programmer/debugger system programs the target using ICSP. VPP, PGC
and PGD lines should be connected as described previously. No clock is required while
programming, and all modes of the processor can be programmed, including code
protection, Watchdog Timer and table read protection.
1 2
Note: In the future, devices with circuitry that support ICD may be used.
The target board must have a connector to accommodate the communications chosen
for the debugger. For connection information, see Section 2.3 “Debugger to Target
Communication”, “Standard ICSP Device Communication”.
Note: In the future, ICD header boards with ICD devices (Device-ICD) may be
used.
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.3 “Debugger to Target Communication”,
“Standard ICSP Device Communication”.
Many Mid-Range PIC microcontrollers and all PIC18 and 16-bit PIC microcontroller
devices do not require an ICD header and can be debugged directly through the ICSP
programming connections.
Note: The target voltage is only used for powering up the drivers for the ICSP
interface; the target voltage does not power up the PICkit 3. The PICkit 3
power is derived strictly from the USB port.
If you have not already done so, connect the PICkit 3 to the target using the appropriate
cables (see Section 3.3 “Connecting the Target”). Then power the target. If you are
powering the target through the PICkit 3, see Section 10.5.8 “Settings Dialog, Power
Tab” for instructions.
Note: If you do not have a custom linker script in your project, the Project
Manager will select the appropriate linker script for you.
Note: PICkit 3 Debug Express requires MPLAB IDE version 8.20 or later.
CAUTION
The DEBUG configuration bit value should not be specified in source code Configura-
tion settings under normal conditions. Doing so may cause the bit to be asserted when
programming a device outside the debugger. This will cause the device to function
improperly or not all at in the application circuit.
Many 16-bit PIC microcontroller devices such as PIC24 and dsPIC33 families have
multiple ICSP programming and debugging port pins labeled PGC1/EMUC1 and
PGD1/EMUD1, PGC2/EMUC2 and PGD2/EMUD2, etc. While any ICSP port may be
used for programming, only one port is active at a time for debugging. The active EMU
port is set in the device Configuration bits. If the active port setting does not match the
EMU port to which the PICkit 3 is connected, the device will be unable to enter debug
mode. In the MPLAB IDE Configuration Bits dialog, these bits are usually referred to as
the “Comm Channel Select” bits.
Note: Although the PICkit 3 unit is capable of programming and debugging, when
using the Programming-To-Go feature, you can only program. No
debugging capabilities are available with Programming-To-Go.
Note 1: Most portable chargers/power devices with their own batteries will not
give an indication when their internal battery voltage gets low and the out-
put drops below 4.5V. Therefore, you must be sure the device’s battery
has sufficient remaining capacity to power the PICkit 3 above 4.5V.
2: Any battery-based power sources should be disconnected from the
PICkit 3 unit when it is not in use. Otherwise, the PICkit 3 unit will drain
the power source battery.
Note 1: Supports all family parts that are supported by MPLAB IDE. See menu
Help > ReadMe for a list of parts supported by the application. Large
memory parts are supported.
2: PICkit 3 Programmer-To-Go does not support using the Programming
Executive (Enhanced ICSP) for these devices. When using PICkit 3
Programmer-To-Go with these parts they will be programmed using low
level ICSP methods.
3: Supported by MPLAB IDE v8.53 or greater.
• In the “Image Name” field, type in the name you want to use for your programming
image.
• The “Programmer Setting Report” panel displays the setting you’ve selected for
programming the device. If you want to change any of these settings, use the
appropriate tab in the PICkit 3 Settings dialog.
• Click Send Image In Memory to execute an image transfer to the PICkit 3 unit.
Once the image is stored in the PICkit 3, you no longer need MPLAB IDE or a PC
to program a device. You can take the PICkit 3 to other locations that may not
have a computer and program a device with the push of a button.
Disconnect the PICkit 3 from the PC USB port. When any USB power source is applied,
the PICkit 3 unit will power-up in Programmer-To-Go mode, indicated by the blinking
“Active” LED.
Note: Press the PICkit 3 push button to clear the error code and initiate a new
programming operation.
Click Yes to preserve the image or No to erase the image. If you select No, the Output
window displays a message similar to Figure 6-4 and exits Programmer-To-Go mode.
• How is the throughput of the processor affected by having to run the debug
executive?
The debug executive doesn’t run while in Run mode, so there is no throughput
reduction when running your code, i.e., the debugger doesn’t ‘steal’ any cycles
from the target device.
• On the MPLAB ICE 2000/4000 debuggers, the data must come out on the
bus in order to perform a complex trigger on that data. Is this also required
on the PICkit 3 programmer/debugger? For example, could I halt based on a
flag going high?
The MPLAB ICE 2000/4000 debuggers use a special debugger chip (-ME) for
monitoring. There is no -ME with the PICkit 3 programmer/debugger so there are
no busses to monitor externally. With the PICkit 3 programmer/debugger, rather
than using external breakpoints, the built-in breakpoint circuitry of the debug
engine is used – the busses and breakpoint logic are monitored inside the part.
Note: Numbers may not yet appear in displayed messages. Use the Search tab
on the Help viewer to find your message and highlight it below.
Text in error messages listed below of the form %x (a variable) will display as text
relevant to your particular situation in the actual error message.
PK3Err0001: Failed while writing to program memory.
PK3Err0002: Failed while writing to EEPROM.
PK3Err0003: Failed while writing to configuration memory.
See Section 9.3.1 “Read/Write Error Actions”.
PK3Err0005: PICkit 3 is currently busy and cannot be unloaded at this time.
If you receive this error when attempting to deselect the debugger as a debugger
or programmer:
1. Wait – give the debugger time to finish any application tasks. Then try to
deselect the debugger again.
2. Select Halt to stop any running applications. Then try to deselect the
debugger again.
3. Unplug the debugger from the PC. Then try to deselect the debugger again.
4. Shut down MPLAB IDE.
PK3Err0006: Failed while writing to user ID memory.
PK3Err0007: Failed while reading program memory.
PK3Err0008: Failed while reading EEPROM.
PK3Err0009: Failed while reading configuration memory.
PK3Err0010: Failed while reading user ID memory.
See Section 9.3.1 “Read/Write Error Actions”.
PK3Err0011: Bulk erase failed.
See Section 9.3.1 “Read/Write Error Actions”.
If these do not work, try another device.
Step Over F8
Execute the instruction at the current program counter location. At a CALL instruction,
Step Over executes the called subroutine and halts at the address following the CALL.
If the Step Over is too long or appears to “hang”, click Halt.
Step Out
Not available.
Reset > Processor Reset F6
Issue a Reset sequence to the target processor. This issues a MCLR to reset the
Program Counter to the Reset vector.
Breakpoints
Open the Breakpoint dialog (see Section 10.3.1 “Breakpoints Dialog”). Use hard-
ware breakpoints to halt code execution at specified lines in your code. Set multiple
breakpoints in this dialog.
Note: You may also right click or double click on a line of code to set a simple
breakpoint.
Program
Download your code to the target device.
Read
Read target memory. Information uploaded to MPLAB IDE.
Erase Flash Device
Erase all Flash memory.
Abort Operation
Abort any programming operation (e.g., program, read, etc.). Terminating an operation
will leave the device in an unknown state.
Reconnect
Attempt to re-establish communications between the PC and the PICkit 3
programmer/debugger. The progress of this connection is shown on the PICkit 3 tab of
the Output dialog.
Settings
Open the PICkit 3 Settings dialog (see Section 10.5 “Settings Dialog”). Set up
program and firmware options.
Once a breakpoint has been added to the window, you may right click on it to open a
menu of options:
• Delete – delete selected breakpoint
• Edit/View – open the Set Breakpoint Dialog
• Delete All – delete all listed breakpoints
• Disable All – disable all listed breakpoints
Note: The tabs displayed will depend on the selected device and whether you
have the PICkit 3 selected as a debugger or a programmer.
Notes:
1. As long as the configuration setting is “MCLR pin
enabled; RA5 input pin disabled”, then you can use Low
Voltage Entry (uncheck the “Use high voltage on MCLR”
option).
2. If you have the configuration setting to “RA5 input pin
enabled; MCLR disabled”, then you must check the
“Use high voltage on MCLR” option.
3. If you want to program the “MCLR pin enable bit” config-
uration setting, you must check the “Use high voltage on
MCLR” option.
4. If you are using a -ICE header, the setting of this check-
box does not matter.
Automatically
Program after successful After the application code successfully builds, program this
build code into the device.
Run after successful program This option is available only in Debug mode.
After the application code is successfully programmed into the
target device, run the code.
A.2 HIGHLIGHTS
This chapter discusses:
• Declaration of Conformity
• USB Port/Power
• PICkit 3 Programmer/Debugger
• Standard Communication Hardware
• Target Board Considerations
Cable Length – The PC-to-debugger cable length for proper operation is shipped in
the debugger kit.
Powered Hubs – If you are going to use a USB hub, make sure it is self-powered. Also,
USB ports on PC keyboards do not have enough power for the debugger to operate.
PC Hibernate/Power-Down Modes – Disable the hibernate or other power saver
modes on your PC to ensure proper USB communications with the debugger.
Note: Older header boards used a 6-pin (RJ-11) connector instead of an 8-pin
connector, so these headers may be connected directly to the debugger.
For more on available header boards, see the “Header Board Specification”
(DS51292).
Target Device
or PIM
Modular Microcontroller
Connector Pin Pin
Front view of Modular Connector
6 PGM (LVP) on Target Board
5 RB6
4 RB7
3 Ground
2 VDD Target
6
1 VPP 1
AC164110
Adapter
Mini-USB
cable
to PC
PICkit™ 3
Device-ICE
Power
Header
Transition Socket
Target Board
USE
ANSI
American National Standards Institute is an organization responsible for formulating
and approving standards in the United States.
Application
A set of software and hardware that may be controlled by a PIC® microcontroller.
NOTES:
01/05/10