ICD2 User Guide 51331c
ICD2 User Guide 51331c
MPLAB® ICD 2
In-Circuit Debugger
User’s Guide
Note the following details of the code protection feature on Microchip devices:
• 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.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron, dsPIC, KEELOQ, KEELOQ logo,
microID, MPLAB, PIC, PICmicro, PICSTART, PRO MATE, rfPIC and SmartShunt are
registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
AmpLab, FilterLab, Linear Active Thermistor, Migratable Memory, MXDEV, MXLAB, SEEVAL,
SmartSensor and The Embedded Control Solutions Company are registered trademarks of
Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, CodeGuard, dsPICDEM, dsPICDEM.net,
dsPICworks, ECAN, ECONOMONITOR, FanSense, FlexROM, fuzzyLAB, In-Circuit Serial
Programming, ICSP, ICEPIC, Mindi, MiWi, MPASM, MPLAB Certified logo, MPLIB, MPLINK,
PICkit, PICDEM, PICDEM.net, PICLAB, PICtail, PowerCal, PowerInfo, PowerMate,
PowerTool, REAL ICE, rfLAB, Select Mode, Smart Serial, SmartTel, Total Endurance, UNI/O,
WiperLock 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.
All other trademarks mentioned herein are property of their respective companies.
© 2007, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.
Printed on recycled paper.
MPLAB® ICD 2
USER’S GUIDE
Table of Contents
Preface ..................................................................... 1
Part 1 –Operation
MPLAB® ICD 2
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® IDE on-line help. Select the Help
menu, and then Topics to open a list of available on-line
help files.
INTRODUCTION
The support information discussed here can help you when using
the MPLAB ICD 2 in-circuit debugger.
Topics covered in this chapter:
• Document Layout
• Conventions Used in this Guide
• Warranty Registration
• Reference Documents
• The Microchip Web Site
• Development Systems Customer Change Notification
Service
• Customer Support
Preface
DOCUMENT LAYOUT
This document describes how to use the MPLAB ICD 2 as a devel-
opment tool to emulate and debug firmware on a target board. The
manual layout is as follows:
• Part 1 – Operation
- Chapter 1. MPLAB ICD 2 Overview – explains the
MPLAB ICD 2, how it helps you and how it works.
- Chapter 2. Getting Started – describes the system com-
ponents, provides installation and configuration instruc-
tions, explains how to set up the environment and
discusses the development process.
- Chapter 3. MPLAB ICD 2 Tutorial – provides a tutorial
using the Project Wizard.
- Chapter 4. Additional Topics – discusses upgrading
firmware, using hex files and linker scripts, and provides
information on ROMless devices and ICD/ICE devices.
- Chapter 5. ICD Function Summary – describes all the
ICD menus, toolbars and dialogs.
• Part 2 – Troubleshooting
- Chapter 6. Troubleshooting Tips – describes the chain
of functionality.
- Chapter 7. Self-Test – discusses the various self-test
features.
- Chapter 8. General Troubleshooting – provides
answers to frequently asked questions, discusses com-
mon problems, and provides error and warning
messages.
• Appendix A. Hardware Specifications – contains informa-
tion on the MPLAB ICD 2 module, the cable and connector,
and power supply.
DOCUMENTATION CONVENTIONS
Description Represents Examples
Arial font:
Italic characters 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 “Save project before
window or dialog build”
Underlined, italic text A menu path File>Save
with right angle
bracket
Bold characters A dialog button Click OK
A tab Click the Power tab
N‘Rnnnn A number in verilog 4‘b0010, 2‘hF1
format, where N is the
total number of digits,
R is the radix and n is
a digit.
Text in angle brackets A key on the keyboard Press <Enter>, <F1>
<>
Preface
DOCUMENTATION CONVENTIONS (CONTINUED)
Description Represents Examples
Courier New font:
Plain Courier New 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 Courier New A variable argument file.o, where file
can be any valid file-
name
Square brackets [ ] Optional arguments mcc18 [options]
file [options]
Curly brackets and Choice of mutually errorlevel {0|1}
pipe character: { | } exclusive arguments;
an OR selection
Ellipses... Replaces repeated var_name [,
text var_name...]
Represents code void main (void)
supplied by 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.
REFERENCE DOCUMENTS
This document describes how to use MPLAB ICD 2. Other useful
documents are listed below.
MPLAB® ICD 2 Design Advisory (DS51566)
Please read this first! Contains important information about using
the MPLAB ICD 2 with your target design.
Readme for MPLAB ICD 2
For the latest information on using MPLAB ICD 2, read the
Readme for MPLAB ICD 2.txt file (an ASCII text file) in the MPLAB
IDE directory. The README file contains update information and
known issues that may not be included in this on-line help file.
Using MPLAB® ICD 2 (DS51265)
A poster showing the various ways you can set up MPLAB ICD 2
hardware.
Header Board Specification (DS51292)
A small booklet describing how to install and use MPLAB ICD 2
headers. Headers are used to better debug selected devices
using special -ICD/ICE device versions, without the loss of pins or
resources.
Universal Programming Module Instruction Sheet (DS51280)
A sheet describing how to use the UPM.
Preface
Preface
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.
Technical support is available through the web site at:
http://support.microchip.com
MPLAB® ICD 2
USER’S GUIDE
Part 1 – Operation
NOTES:
MPLAB® ICD 2
USER’S GUIDE
Chapter 1. MPLAB ICD 2 Overview
1.1 INTRODUCTION
An overview of the MPLAB ICD 2 development tool is given here.
MPLAB ICD 2 is defined and its operation explained. Additionally,
device resources used during debugging are listed.
Topics covered in this chapter are:
• What is MPLAB ICD 2?
• How MPLAB ICD 2 Helps You
• How MPLAB ICD 2 Works
• Resources Used By MPLAB ICD 2
MPLAB® ICD 2
Connector
PGD
VDD 2 4 6
PGC
1 3 5 Target
VPP/MCLR VSS PC Board
Bottom Side
Not all PIC MCUs have the AVDD and AVSS lines, but if they are
present on the target PIC MCU, all must be connected in order for
MPLAB ICD 2 to operate.
1 VPP/MCLR
No!
No!
No!
5 PGC
4
PGD
No!
Programming VDD
Voltage
+5V 1
MPLAB® ICD 2 VPP/MCLR
Internal Circuits
4.7KΩ 5
PGC
4
PGD
4.7KΩ
VSS
Internal Target
VDD must
Debug be
Registers Running
+12V for Debug
1 Executive
+5V VPP/MCLR
MPLAB® ICD 2 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
About 0x50
Bytes Used by File
Debug Exec Registers
MPLAB® ICD 2
USER’S GUIDE
Chapter 2. Getting Started
2.1 INTRODUCTION
The use of MPLAB ICD 2 with MPLAB IDE software and an expla-
nation of power options and recommended power-up sequences
are discussed here. Following this is a step-by-step tutorial using
MPLAB ICD 2. Before continuing on to the tutorial, be sure that the
software and hardware is configured according to the instructions
given here.
In addition, please refer to the “MPLAB ICD 2 Design Advisory”
(DS51566) for hardware configuration issues.
Topics covered in this chapter:
• MPLAB ICD 2 System Components
• Installing and Configuring MPLAB IDE for MPLAB ICD 2
• Applying Power
• Connection Options
• Setting Up the Environment
• MPLAB ICD 2 Development Process
Getting Started
To install the MPLAB IDE software, first acquire the latest MPLAB
IDE installation executable (MPxxxxx.exe, where xxxxx
represents the version of MPLAB IDE) from either the Microchip
web site (www.microchip.com) or the MPLAB IDE CD-ROM
(DS51123).
• Setting Up Communications
• Starting MPLAB IDE
• Select the Device
• Set MPLAB ICD 2 as the Debug Tool
• Configure the Interface
Getting Started
After starting MPLAB IDE, it will need to be configured for MPLAB
ICD 2 use:
1. Select a device supported by MPLAB ICD 2.
2. Set MPLAB ICD 2 as the current debugger.
3. Configure the MPLAB ICD 2 RS-232 or USB interface.
Getting Started
5. In the Settings dialog, click the Power tab and ensure that
the check box for “Power target circuit from MPLAB ICD 2”
is checked. Click OK.
Note: If any of the self-tests on the Status tab of the
Settings dialog do not pass, it may not be possible to
erase and program chips. See Section 7.7 “Failed
Self-Test Error – Vpp/Vdd High/Low” for more
information.
Getting Started
• ICD Settings dialog (Debugger>Settings or
Programmer>Settings) – Set up communications, power, pro-
gramming and warning message output, as well as view
status, limitations, and version information.
You have previously used the Communications and Power
tabs when setting up the MPLAB ICD 2 hardware. The follow-
ing tabs are useful for completing the ICD setup. For detailed
information on these and the other tabs on the Settings
dialog, see Section 5.4 “Settings Dialog”.
- Program tab – Set up programming options (Select
Memories, Program and External Memory Ranges, ID,
and Program Options, Erase All). If programming the ID
bits is desired, set the value to be programmed in the
Configure>ID Memory dialog.
- Warning tab – Determine which warning messages will
be displayed. Can be useful to select messages if they
are to be outputted to a file (see Status tab.)
- Status tab – In addition to auto-connect on startup and
self-test control, output messages may be selected to be
logged to a file. These messages may assist users or, if
necessary, Microchip technical support in finding errors.
Getting Started
2.7.2.1 REAL-TIME EXECUTION
Real-time execution occurs when the device in the
demo/application board is put in MPLAB IDE's Run mode.
When the MPLAB ICD 2 is run in real time, instructions execute
just as the processor would without the debugger. While in the Run
mode, register displays on the screen will not update.
To execute the code in real-time:
1. Open the source file (double click on the file name in the
Project Window or use File>Open) or program memory
window (View>Program Memory) for viewing.
2. Select Debugger>Run (or click the toolbar Run button).
The processor will run until a breakpoint is reached or until the
processor is halted by selecting Debugger>Halt (or clicking the
toolbar Halt button).
2.7.2.2 BREAKPOINTS
Breakpoints allow you to specify conditional program halts so that
you may observe memory, register or variable values after a run-
time execution. You may set breakpoints in either the file (editor)
window, the program memory window or the disassembly window.
You may set a breakpoint using either:
• Right mouse button menu – click on the line in code at which
you wish to set a breakpoint and select Set Breakpoint.
• Breakpoint dialog – open the dialog and enter a breakpoint at
a specific address
Note: For most devices, only one breakpoint will be set
(active) at a time, although you may specify more
than one breakpoint in the breakpoint dialog (i.e., one
breakpoint will be active and the others will be
inactive).
Getting Started
2.7.4 Finishing the Application: Using MPLAB ICD 2
as a Programmer
Once the code has been debugged and the application is running
as designed, the device can be programmed without the debugger
enabled. The device resources reserved for ICD operation then
will be free for other use.
Getting Started
2.7.5.3 ERASE/BLANK CHECK A DEVICE
From the Programmer menu or toolbar, select the following items
to erase and then blank check a device:
• Erase Device – Select Erase to erase the device memory.
Note: Internal oscillator and bandgap calibration bits are
always preserved by MPLAB ICD 2 for the erase
cycle. Only during programming may their values be
changed.
MPLAB® ICD 2
USER’S GUIDE
Chapter 3. MPLAB ICD 2 Tutorial
3.1 INTRODUCTION
This tutorial walks you through the process of developing a simple
project using the sample program, TUT452.asm, found in the
directory C:\Program Files\Microchip\MPASM
Suite\Example. This program is an implementation of the
PIC18F452 analog-to-digital (A/D) converter using the PICDEM™
2 Plus Demo Board (DM163022). The program configures the A/D
module to convert input from A/D channel 0 (connected to the
potentiometer on the demo board) and display the results on the
four PORTB LEDs (RB3:RB0).
Topics covered in this chapter:
• Setting Up The Environment
• Running the Project Wizard
• Viewing the Project
• Creating a Hex File
• Setting Debug Options
• Setting Up the Demo Board
• Loading Program Code For Debugging
• Running TUT452
• Debugging TUT452
• Programming the Application
• TUT452 Main Routine and Source Code
6. The second file needed for this project is the linker script.
Click on the C:\Program Files\Microchip\MPASM
Suite\LKR folder to expand it, and then scroll down to
select the file 18F452i.lkr. Make sure that the file name
has an “i.”
Press ADD>> to move the linker script to the list on the right.
You will not be copying this file into the project directory.
Additional files can be added to the project using the project win-
dow. Right click on any line in the project window tree to pop up a
menu with additional options for adding and removing files.
Based on the halt location and the fact that the program
never reaches the breakpoint, it can be concluded that the
problem is in the A/D conversion. The A/D flag for conver-
sion complete is not being set. A/D conversion initialization
and setup occurs at the beginning of the program.
6. To reset the program, select Debugger>Reset. The first
instruction should be indicated with a green arrow.
7. Open a new Watch window to watch the A/D register value
change as the program executes. Select View>Watch. The
Watch dialog opens with the Watch_1 tab selected. Select
“ADCON0” from the list next to Add SFR, and then click the
button. ADCON0 is added to the Watch window. Repeat for
ADCON1. The selected symbols should now be visible in
the Watch window as shown in Figure 3-12.
10. Single step five times, select Debugger>Step (or click the
Step toolbar button) to single step through the program. The
following line of code should be indicated when finished:
movlw B'11000111' ;TMR0 prescaler, 1:256
11. Examine the values of the registers ADCON0 and ADCON1
in the Watch window. Notice that ADCON0 has a value of 40
HEX. This corresponds to the binary value designated in the
program, but is this value correct?
A review of the PIC18F452 Data Sheet (DS39564) section
on A/D, indicates that the last bit should be a one, not a zero,
to turn the A/D module on.
To fix this bug, change:
movlw B'01000000';Fosc/8, A/D enabled
to:
movlw B'01000001';Fosc/8, A/D enabled
12. Select File>Save to save the changes.
13. Select Project>Build All to rebuild the project. A message
will indicate that the program has been rebuilt. The MPLAB
ICD 2 must be reprogrammed for the changes to take effect.
START
Configure PORTB
as All Outputs
Configure A/D
left justify, FOSC/8 clock
1 analog channel
Configure Timer0
Prescaler assigned to Timer0
1:256 prescale
No
Timer0 Overflow?
Yes
No
Conversion
Complete?
Yes
list p=18f452
include "p18f452.inc"
Main
btfss INTCON,TMR0IF ;Wait for Timer0
;to timeout
goto Main
bcf INTCON,TMR0IF
movwf PORTB
goto Main ;Do it again
end
MPLAB® ICD 2
USER’S GUIDE
Chapter 4. Additional Topics
4.1 INTRODUCTION
As you work with MPLAB ICD 2 to develop your application, these
are some additional topics that you may find useful.
Topics covered in this chapter are:
• Upgrading the MPLAB ICD 2 Firmware (Operating System)
• Creating/Loading a Hex File
• Special Linker Script Files
• ROMless Device Considerations
• ICD/ICE Devices
Additional Topics
4.3.3 Hex File Requirements
Whatever tool you use to develop your hex code, please keep in
mind the following:
• Your code should be limited depending on the device
because a portion of program memory on the device is
reserved.
• The start of EEPROM data memory needs to be specified.
For most PIC MCU’s, the start should be at 0x2100 (org
H‘2100’). For PIC18FXXXX devices, the start should be at
0xF00000 (org H‘F00000’). Please check the programming
specification for your selected device to determine the correct
address.
Additional Topics
4.5.3 External Memory
This section only applies to ROMless (PIC18C601/801) devices.
File Click the Browse button to select the location of the
WriteProgramWord and EraseProgramMemory files.
See PICDEM 18R Files.
You must use a different memory routine file for the
8-bit bus width and the 16-bit bus width devices. The
memory routine files must match the following
naming conventions:
<Memory Type><Bus Width>.<extension>
where <Memory Type><Bus Width> does not
exceed 8 characters.
Valid 16-bit filename examples:
29F16016.hex
SRAM16.hex
Valid 8-bit filename examples:
29F16008.hex
SRAM08.hex
See the \ICD801\Source folder for information
on writing your custom routines. These code routines
will be used to program memory. They must be relo-
catable and comply with the format used in the
included source files.
Use Default Pro- Select this option to use the default memory routines
gram Routines provided with MPLAB IDE instead of providing your
own memory routines.
See PICDEM 18R Files.
MPLAB® ICD 2
USER’S GUIDE
Chapter 5. ICD Function Summary
5.1 INTRODUCTION
When you select MPLAB ICD 2 from the Debugger menu,
debugging functions will be added to MPLAB IDE.
When you select MPLAB ICD 2 from the Programmer menu,
programming functions will be added to MPLAB IDE.
The functions made available are summarized here.
MPLAB ICD 2 functions are added to MPLAB IDE as follows:
• Debugging Functions
• Programming Functions
• Settings Dialog
• Setup Wizard
• Advanced Breakpoints Dialog
Advanced Breakpoints
Open the Advanced Breakpoint dialog. Setup advanced
breakpoint features for devices that support this ICD feature.
MPLAB ICD 2 Setup Wizard
Launch the wizard to help you set up the MPLAB ICD 2.
Program
Download the debug executive module (if selected in Program
tab) and your code to the target device.
Read
Read target memory. Information uploaded to MPLAB IDE.
Read EEPROM
Read device EEPROM data and then reset.
5.2.2 Toolbars
When the MPLAB ICD 2 is selected as a debugger, these toolbars
are displayed in MPLAB IDE:
• Standard debug toolbar (Run, Halt, Step Into, Step Over,
Reset). See MPLAB IDE Help for more information.
• MPLAB ICD 2 debug toolbar (Program Target Device, Read
Target Device, Read device EEPROM, Reset and Connect to
ICD).
5.3.2 Toolbar
Program target device
Program specified memory areas: program memory,
Configuration bits, ID locations and/or EEPROM data.
Read target device
Read specified memory areas: program memory, Configuration
bits, ID locations and/or EEPROM data.
Note: If you are using the MPLAB ICD 2, you must check the
“Automatically Program after successful build” in the
MPLAB ICD 2 settings dialog on the Program tab. Do
not check “Automatically Run after successful
program.”
CAUTION
If there is a device other than the MPLAB ICD 2 on the port when
you auto-connect, damage to that device may result.
Breakpoint Number
These devices support up to three breakpoints. Enter a number
and then set up that breakpoint below. Change the number to set
up another breakpoint.
Breakpoint Number
These devices support up to three breakpoints. Enter a number
and then set up that breakpoint below. Change the number to set
up another breakpoint.
Data Sample
Check this checkbox if the breakpoint will signify the start of data
sampling. Then:
• File Register Address – Enter location of breakpoint.
Data samples will appear in the Output window under the ICD2
Data Sample tab. To have this information scroll, select “Scroll
Data Sample Output” under Section 5.6.3.2 “Emulator
Features”.
Event Breakpoints
For all breakpoints:
• Break on Stack Over/Underflow – Break on stack overflow or
underflow. (Future feature)
• Break on Watchdog Timer – Break on a WDT time-out.
(Future feature)
• Break on SLEEP – Break on a SLEEP instruction. The SLEEP
instruction will NOT be executed. Running or stepping from
this point will execute the instruction after SLEEP.
Enable Stopwatch
Check to coordinate breakpoints with Stopwatch operation.
• Halt on Start Condition (Breakpoint 2)
- If checked, halt program (breakpoint 2 enabled) and
program/Stopwatch go on Run.
- If unchecked, program continues to run (breakpoint 2
disabled) and Stopwatch is started.
• Halt on Stop Condition (Breakpoint 3)
- If checked, halt program (breakpoint 3 enabled) and
Stopwatch.
- If unchecked, program continues to run (breakpoint 3
disabled), but Stopwatch halted.
• Reset Stopwatch on Run – Any time you run the program,
reset the stopwatch to zero.
Breakpoint Combinations
This section is grayed out unless there are two breakpoints. The
options are:
• Both breakpoints must occur at the same time to cause a
break.
• Breakpoint 0/1 does not break until after breakpoint 1/0
occurs – Click Swap BPs to change the order.
Breakpoints
Breakpoint # Select a breakpoint to set up, either 0 or 1.
Breakpoint Type Select the type of breakpoint. Options below will
change depending on the selection made here.
Disabled – Breakpoint disabled (default). Other
options grayed out.
Other Selections – See tables below.
Breakpoints
Breakpoint # Select a breakpoint to set up, either 0 or 1.
Breakpoint Type Select the type of breakpoint. Options below will
change depending on the selection made here.
Disabled – Breakpoint disabled (default). Other
options grayed out.
Other Selections – See tables below.
ANDED Breakpoints
Check the checkbox next to each breakpoint to AND together.
Breakpoint Sequencing
Select a breakpoint sequence.
Swap Breakpoints
Choose one breakpoint to swap with another.
Event Breakpoints
For all breakpoints:
• Break on Watchdog Timer – Break on a WDT time-out.
• Break on SLEEP – Break on a SLEEP instruction. The SLEEP
instruction will NOT be executed. Running or stepping from
this point will execute the instruction after SLEEP.
Enable Stopwatch
Check to coordinate breakpoints with Stopwatch operation.
• Halt on Start Condition (Breakpoint 1)
- If checked, halt program (breakpoint 1 enabled) and
program/Stopwatch go on Run.
- If unchecked, program continues to run (breakpoint 1
disabled) and Stopwatch is started.
• Halt on Stop Condition (Breakpoint 0)
MPLAB ICD 2
USER’S GUIDE
Part 2 – Troubleshooting
Chapter 6. Troubleshooting Tips ........................................... 97
Chapter 7. Self-Test ............................................................... 105
Chapter 8. General Troubleshooting ................................... 109
MPLAB® ICD 2
USER’S GUIDE
Chapter 6. Troubleshooting Tips
6.1 INTRODUCTION
Since many things in MPLAB IDE, MPLAB ICD 2 and the PIC
MCU target application circuit can affect the operation of MPLAB
ICD 2, it is important to understand the operation of each link in the
chain of ICD functionality.
Figure 6-1 is a diagram showing the various links. Each link must
be functional for MPLAB ICD 2 to program and debug. This
section discusses these links to help find and fix problems if they
occur.
Target
OSC
Troubleshooting Tips
If MPLAB ICD 2 does not have voltage on its VDD line (pin 2 of the
ICD connector) it will not operate. Using a scope, communications
on PGC and PGD with a full target VDD to VSS peak-to-peak
waveform should be seen. VPP should show +12, +5, and 0V
levels depending upon the operation being performed. Signals
should be seen on those lines only after performing an MPLAB
ICD 2 function from the MPLAB user interface. Otherwise, all
these lines should be idle and noise free.
Troubleshooting Tips
Troubleshooting Tips
in-circuit debug registers are enabled. The line labeled “Back-
ground Debug” should say “Enabled.” Programming should be
done from the Debug menu, not the Programmer Menu.
MPLAB® ICD 2
USER’S GUIDE
Chapter 7. Self-Test
7.1 INTRODUCTION
The Run Self Test button (Settings dialog, Status tab) is helpful
in determining problems with the MPLAB ICD 2 module or target
connection.
Self-Test features covered are:
• Target VDD
• Module VPP
• MCLR = GND
• MCLR = VDD
• MCLR = VPP
• Failed Self-Test Error – VPP/VDD High/Low
Self-Test
Cause:
This could be due to the firmware routines used to determine
minimum and maximum voltages (a less than compare is used in
one place while a less-than or equal-to is used in another).
Solution:
Check the actual voltages measured by the ICD. This can be
found at Programmer/Debugger>Settings>Power. The Update
button will cause these voltages to be remeasured and displayed.
As long as the voltages displayed are within tolerance for the
target device, the MPLAB ICD 2 unit can still be used for
programming and debugging operations.
The firmware will be changed for better support of self-test
functions.
MPLAB® ICD 2
USER’S GUIDE
Chapter 8. General Troubleshooting
8.1 INTRODUCTION
Frequently Asked Questions (FAQs) and common problems are
documented here to help you as you use the MPLAB ICD 2. Also,
messages generated by the ICD and its tool limitations are
referenced.
Topics covered in this chapter are:
• Frequently Asked Questions
• Common Communication Problems
• Common Problems
• Error and Warning Messages
• Limitations
General Troubleshooting
FIGURE 8-1: SYSTEM PROPERTIES DIALOG
General Troubleshooting
tion settings when debugging with MPLAB ICD 2. Code protection
can be enabled when programming a part for testing without
MPLAB ICD 2.
General Troubleshooting
“MCLR=VPP” (all other tests will probably pass).
• Use the default address range for the target controller and
execute a “Program” cycle. A voltage level on pin 1 (VPP) of
7-8 volts is too low.
If the target was wired backwards, protection circuitry in the
MPLAB ICD 2 will prevent damage to the module. Normal
operation should be seen when the target is wired correctly.
The Error LED flashing indicates an over-voltage condition on
either the clock or data line on the ICSP interface. This circuitry is
in place to protect the buffers on the MPLAB ICD 2 from being
damaged. When a high voltage is detected greater than 6.5V a
clamping circuit brings the clock and data line low. Once this error
occurs, MPLAB will need to be reinitialized and the fault removed
for operation to resume normally.
General Troubleshooting
8.2.24 Why can’t I step through a return for my
dsPIC30F device?
Make sure that you have:
• checked the option to build for ICD, i.e., go to Project>Build
Options>Project, MPLAB LINK30 tab, and check “Link for
ICD2”.
• initialized the software stack, i.e., use the startup module
libpic30.a (for MPLAB C30) or crt0.o (for MPLAB
ASM30) or consult a template to write your own SP and
SPLIM initialization code.
Then you should able to step through a return (from a function,
etc.)
8.3.1.1 IN GENERAL
1. Check that the RS-232 or USB cable is connected securely
to the MPLAB ICD 2 and the host computer.
2. Check that the modular cable is connected securely to the
demo board/target application and the MPLAB ICD 2
module.
3. Make sure there is power to the demo board/target applica-
tion. Check VDD Source in the MPLAB ICD 2 Settings
dialog, Power tab.
General Troubleshooting
6. If you have a COM port but MPLAB IDE will not let you
select it (the option is grayed out) you may be able to assign
the port manually by editing the mplab.ini file. Typically,
this occurs if you have a gap in your COM port list (i.e., you
have a COM1, COM2, and a COM4, but no COM3). In this
case you may be able to fix it by opening mplab.ini (use
Find to locate this file) and editing the section called [MPLAB
ICD 2] so that the setting CommPort=1 is set to the port
you want selected. This is just a work-around to a deeper
problem in which Windows is incorrectly reporting port
availability through the 16-bit driver.
General Troubleshooting
8.3.1.4 USB COMMUNICATIONS
CAUTION
If the Windows OS picked a USB driver, MPLAB ICD 2 will not
work. Follow the instructions in ICD2\Drivers\clnicd2.htm of the
MPLAB IDE installation directory to remove the Windows drivers
and replace them with the correct USB drivers.
General Troubleshooting
8.4.2 Can't uncheck programming of Configuration
bits in Debug mode
For MPLAB ICD 2 to function in Debug mode, the ICD must
ensure that the Background Debug Configuration bit is pro-
grammed on the target. Therefore, configuration memory is
always programmed when in Debug mode.
General Troubleshooting
8.4.12 Execute Reset or MCLR command, program
does not rerun
When you select Debugger>Reset to reset the program, it will go
to zero and halt. The Reset command will not rerun the program
when the MPLAB ICD 2 is in Debug mode.
8.6 LIMITATIONS
MPLAB ICD 2 has limitations for both its debugger and program-
mer modes. These, and additional device-specific limitations, may
be found in on-line help for MPLAB ICD 2.
NOTES:
MPLAB® ICD 2
USER’S GUIDE
Appendix A. Hardware Specifications
A.1 INTRODUCTION
Hardware specifications for MPLAB ICD 2 system components
are listed here.
In addition, please refer to the “MPLAB ICD 2 Design Advisory”
(DS51566) for hardware configuration issues.
Topics covered in this chapter are:
• MPLAB ICD 2 Module
• Modular Cable and Connector
• Power Supply
Hardware Specifications
FIGURE A-1: MODULAR CONNECTOR PINOUT OF
DESIGNER'S BOARD
Hardware Specifications
MPLAB® ICD 2
USER’S GUIDE
Index
A
Abort ................................................................................... 72, 74
Additional .................................................................................. 63
Advanced Breakpoint Dialog
dsPIC30F Devices ............................................................. 89
dsPIC33F Devices ............................................................. 91
Extended PIC18F Devices ................................................. 85
Extended PIC18F Devices V2 ........................................... 86
PIC18F Devices ................................................................. 84
PIC24F Devices ................................................................. 91
Animate .................................................................................... 70
Application Code .................................................................... 102
AVDD ................................................................................ 17, 102
AVSS ................................................................................. 17, 102
B
Blank Check ....................................................................... 39, 74
Blinking LED ........................................................................... 114
Breakpoints ........................................................................ 35, 71
Advanced ................................................... 84, 85, 86, 89, 91
Setting ........................................................................ 53, 116
BSR Register .......................................................................... 115
Build-In Debug Circuitry ........................................................... 68
C
Calibration Data .............................................................. 113, 116
CALL FAST .................................................................... 103, 115
Capacitors ................................................................................ 18
Circuits that Interfere with MPLAB ICD 2 ................................. 18
Code Protect ............................................................ 20, 103, 112
Communications ....................................................................... 27
Index
F
Fast
Call ........................................................................... 103, 115
Interrupts .......................................................................... 103
Return .............................................................................. 115
Firmware ............................................................................ 43, 99
Firmware Upgrades .................................................................. 63
Frequently .............................................................................. 109
G
Getting Started ......................................................................... 25
GP1/RA1 ................................................................................ 114
GPIO ...................................................................................... 114
Green Light ......................................................................... 29, 42
H
Halt ........................................................................................... 70
Header Board ............................................................. 24, 26, 109
Specification .................................................................. 6, 68
Hex File ........................................................................ 36, 48, 64
Hold in Reset ............................................................................ 74
How MPLAB ICD 2 Works ........................................................ 14
I
ICD ........................................................................................... 99
Cable ................................................................................. 16
Devices .............................................................................. 68
Header Adapters .............................................................. 109
ICE Devices .............................................................................. 68
ICE vs ICD ................................................................................ 14
ICSP ................................................................................... 20, 24
Installation ................................................................................ 27
Interconnections ....................................................................... 16
Internal Buffer Circuits ............................................................ 100
Internet Address ......................................................................... 7
Interrupts ................................................................................ 114
Fast .................................................................................. 103
High Priority ..................................................................... 115
Index
R
Read ................................................................................... 71, 73
Read a Device .......................................................................... 38
Read EEPROM ........................................................................ 71
Real-Time Execution ................................................................ 35
Red Light .................................................................................. 29
Release from Reset .................................................................. 74
Reserved Resources ................................................................ 24
Reset
Hold in ................................................................................ 74
Processor ........................................................................... 71
Release from ..................................................................... 74
Resistors .................................................................................. 18
RETFIE .................................................................................. 115
RETURN FAST ........................................................................ 115
ROMless Devices ..................................................................... 65
RS-232 ..................................................................................... 26
Run ........................................................................................... 70
S
Selecting Device and Development Mode ............................... 42
Self Test ................................................................................. 115
Set Breakpoint .......................................................................... 53
Setting Program and Debug Options ....................................... 48
Setting Up Hardware and Software .......................................... 42
Settings Dialog ......................................................................... 33
Setup Wizard ...................................................................... 43, 81
Shadow Stack ........................................................................ 103
Single Stepping ...................................................................... 116
Status Register ....................................................................... 115
Step .......................................................................................... 70
Step-Mode Execution ............................................................... 36
System Components ................................................................ 26
Index
NOTES:
Index
NOTES: