MPLAB User Guide
MPLAB User Guide
DS51766B
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 Microchips 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 Microchips 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 buyers 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, dsPIC, KEELOQ, KEELOQ logo, MPLAB, PIC, PICmicro, PICSTART, PIC32 logo, rfPIC 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, MXDEV, MXLAB, SEEVAL 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, dsSPEAK, ECAN, ECONOMONITOR, FanSense, HI-TIDE, In-Circuit Serial Programming, ICSP, Mindi, MiWi, MPASM, MPLAB Certified logo, MPLIB, MPLINK, mTouch, Octopus, Omniscient Code Generation, PICC, PICC-18, PICDEM, PICDEM.net, PICkit, PICtail, REAL ICE, rfLAB, Select Mode, Total Endurance, TSHARC, UniWinDriver, 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. 2010, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved. Printed on recycled paper. ISBN: 978-1-60932-393-6
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 Companys 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, Microchips quality system for the design and manufacture of development systems is ISO 9001:2000 certified.
DS51766B-page 2
Chapter 2. Operation
2.1 Introduction ................................................................................................... 17 2.2 MPLAB ICD 3 In-Circuit Debugger vs. MPLAB ICE 2000/4000 In-Circuit Emulators ............................................................................................... 17 2.3 MPLAB ICD 3 In-Circuit Debugger vs. MPLAB ICD 2 Debugger ................. 17 2.4 Debugger To Target Communication ........................................................... 18 2.5 Communication Connections ....................................................................... 19 2.6 Debugging with the Debugger ...................................................................... 21 2.7 Requirements For Debugging ...................................................................... 22 2.8 Programming with the Debugger .................................................................. 24 2.9 Resources Used by the Debugger ............................................................... 24
Chapter 3. Installation
3.1 Introduction ................................................................................................... 25 3.2 Installing the Software .................................................................................. 25 3.3 Installing the USB Device Drivers ................................................................ 25 3.4 Using the ICD 3 Test Interface Board .......................................................... 25 3.5 Connecting the Target .................................................................................. 26 3.6 Setting Up the Target Board ......................................................................... 26 3.7 Setting Up MPLAB IDE ................................................................................ 27
DS51766B-page 3
DS51766B-page 4
Table of Contents
Glossary ....................................................................................................................... 97 Index ........................................................................................................................... 117 Worldwide Sales and Service .................................................................................. 120
DS51766B-page 5
DS51766B-page 6
INTRODUCTION
This chapter contains general information that will be useful to know before using the MPLAB ICD 3 in-circuit debugger. Items discussed in this chapter 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 MPLAB ICD 3 in-circuit debugger as a development tool to emulate and debug firmware on a target board, as well as how to program devices. The document is organized as follows:
DS51766B-page 7
Part 3 Reference
Chapter 8. Basic Debug Functions A description of basic debugger features available in MPLAB IDE when the MPLAB ICD 3 in-circuit debugger is chosen as either the debug or programming tool. This includes the debug features breakpoints, stopwatch, triggering and real-time watches. Chapter 9. Debugger Function Summary A summary of debugger functions available in MPLAB IDE when the MPLAB ICD 3 debugger is chosen as the debug or program tool. Appendix A. Hardware Specification The hardware and electrical specifications of the debugger system.
DS51766B-page 8
Preface
CONVENTIONS USED IN THIS GUIDE
This manual uses the following documentation conventions: DOCUMENTATION CONVENTIONS
Description Arial font: Italic characters Initial caps Represents Referenced books Emphasized text A window A dialog A menu selection A field name in a window or dialog A menu path A dialog button A tab A number in verilog format, where N is the total number of digits, R is the radix and n is a digit. A key on the keyboard Sample source code Filenames File paths Keywords Command-line options Bit values Constants A variable argument Optional arguments Choice of mutually exclusive arguments; an OR selection Replaces repeated text Represents code supplied by user Examples MPLAB IDE Users Guide ...is the only compiler... the Output window the Settings dialog select Enable Programmer Save project before build File>Save Click OK Click the Power tab 4b0010, 2hF1
Quotes Underlined, italic text with right angle bracket Bold characters NRnnnn
Text in angle brackets < > Courier New font: Plain Courier New
Press <Enter>, <F1> #define START autoexec.bat c:\mcc18\h _asm, _endasm, static -Opa+, -Opa0, 1 0xFF, A file.o, where file can be any valid filename mcc18 [options] file [options] errorlevel {0|1} var_name [, var_name...] void main (void) { ... }
Italic Courier New Square brackets [ ] Curly brackets and pipe character: { | } Ellipses...
DS51766B-page 9
RECOMMENDED READING
This user's guide describes how to use MPLAB ICD 3 in-circuit debugger. Other useful documents are listed below. The following Microchip documents are available and recommended as supplemental reference resources.
DS51766B-page 10
Preface
THE MICROCHIP WEB SITE
Microchip provides online support via our web site at www.microchip.com. This web site is used as a means to make files and information easily available to customers. Accessible by using your favorite Internet browser, the web site contains the following information: Product Support Data sheets and errata, application notes and sample programs, design resources, users guides and hardware support documents, latest software releases and archived software General Technical Support Frequently Asked Questions (FAQs), technical support requests, online discussion groups, Microchip consultant program member listing Business of Microchip Product selector and ordering guides, latest Microchip press releases, listing of seminars and events, listings of Microchip sales offices, distributors and factory representatives
DS51766B-page 11
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.
REVISION HISTORY
Revision A (September 2008)
This is the initial release of this document.
DS51766B-page 12
DS51766B-page 13
DS51766B-page 14
1.2
DS51766B-page 15
1.4
Additional hardware that may be ordered separately: Transition socket ICD headers MPLAB IDE processor extension kits
DS51766B-page 16
2.2
MPLAB ICD 3 IN-CIRCUIT DEBUGGER VS. MPLAB ICE 2000/4000 IN-CIRCUIT EMULATORS
The MPLAB ICD 3 in-circuit debugger system is a next generation In-Circuit Debugger (ICD) system. It differs from classical in-circuit emulator systems (e.g., MPLAB ICE 2000/4000) in a single, but important way: the production device and emulation device are the same. This is a great benefit since differences (errata) between the production silicon and emulation silicon are eliminated. Additionally, as devices continue to operate at faster speeds, traditional emulator systems present bottlenecks caused by internal busses that must be carried off-chip to external memories and cannot offer full speed emulation. Another significant benefit is that there is no lead time between production silicon and emulation silicon. Further, a problem encountered on a production board can be easily debugged without having to install transition sockets and dealing with complicated cabling systems and setups to have access to the application.
2.3
DS51766B-page 17
CAUTION
Do not connect the hardware before installing the software and USB drivers. Also, do not change hardware connections when the pod or target is powered.
For more on standard communication, see Appendix A. Hardware Specification. FIGURE 2-1: STANDARD DEBUGGER SYSTEM DEVICE WITH ON-BOARD ICE CIRCUITRY
Target Board
Power
DS51766B-page 18
Operation
FIGURE 2-2: STANDARD DEBUGGER SYSTEM ICE DEVICE
Processor Pak
Header
Device-ICE
Standard Adapter
OR
ICD Header
Transition Socket Device-ICE
Target Board
Power
2.5
COMMUNICATION CONNECTIONS
2.5.1 Standard Communication Target Connection
Using the RJ-11 connector, the MPLAB ICD 3 in-circuit debugger is connected to the target device with the modular interface (six conductor) cable. The pin numbering for the connector is shown from the bottom of the target PC board in Figure 2-3. 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. STANDARD CONNECTION AT TARGET Target Connector
VDD PGD LVP 2 4 6 PGC 1 3 5 Target Vss
FIGURE 2-3:
VPP/MCLR
2.5.2
Figure 2-4 shows the interconnections of the MPLAB ICD 3 in-circuit debugger to the connector on the target board. The diagram also shows the wiring from the connector to a device on the target PC board. A pull-up resistor (usually around 10 k) is recommended to be connected from the VPP/MCLR line to VDD so that the line may be strobed low to reset the device.
DS51766B-page 19
2.5.3
Target Powered
In the following descriptions, only three lines are active and relevant to core debugger operation: pins 1 (VPP/MCLR), 5 (PGC) and 4 (PGD). Pins 2 (VDD) and 3 (VSS) are shown on Figure 2-4 for completeness. MPLAB ICD 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 VDD is sensed by the debugger to allow level translation for the target low voltage operation. If the debugger does not sense voltage on its VDD line (pin 2 of the interface connector), it will not allow communication with the target.
2.5.4
Debugger Powered
The internal debugger power is limited in two aspects: (1) the voltage range is not as wide (3-5V); and (2) the amount of current it can supply is limited to 100 mA. This may be of benefit for very small applications that have the device VDD separated from the rest of the application circuit for independent programming, but is not recommended for general usage as it imposes more current demands from the USB power system derived from the PC. Be aware that the target VDD is sensed by the debugger to allow level translation for target low-voltage operation. If the debugger does not sense voltage on its VDD line (pin 2 of the interface connector), it will not allow communication with the target. Not all devices have the AVDD 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. In general, it is recommended that all VDD/AVDD and VSS/AVSS lines be connected to the appropriate levels. Also, devices with a VCAP line (PIC18FXXJ for example) should be connected to the appropriate capacitor or level. Note: The interconnection is very simple. Any problems experienced are often caused by other connections or components on these critical lines that interfere with the operation of the MPLAB ICD 3 in-circuit debugger system, as discussed in the following section.
DS51766B-page 20
Operation
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 MPLAB ICD 3 in-circuit debugger system from functioning. FIGURE 2-5: IMPROPER CIRCUIT COMPONENTS
1 No! No! No! PGC PGD No! 5 4 Interface Connector
VPP/MCLR
Specifically, 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.
2.6
DS51766B-page 21
+5V
PGC PGD
A simplified diagram of some of the internal interface circuitry of the MPLAB ICD 3 in-circuit debugger 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 VPP/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.
2.7
DS51766B-page 22
Operation
2.7.1 Sequence of Operations Leading to Debugging
Given that the Requirements For Debugging are met, these actions can be performed when the MPLAB ICD 3 in-circuit debugger is set as the current debugger from the MPLAB IDE menu (Debugger>Select Tool>MPLAB ICD 3): The application code is compiled/assembled by selecting Project>Build Configuration>Debug. When Debugger>Program is selected, the application code is programmed into the devices memory via the ICSP protocol as described above. A small debug executive program is loaded into the high area of program memory of 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. These allow the debug executive to be activated by the debugger. The target device is held in Reset by keeping the VPP/MCLR line low.
2.7.2
Debugging Details
Figure 2-7 illustrates the MPLAB ICD 3 in-circuit debugger system when it is ready for debugging. FIGURE 2-7: MPLAB ICD 3 IN-CIRCUIT DEBUGGER READY FOR DEBUGGING
VDD +12V +5V
Internal Circuits
VPP/MCLR
Target must be Running for Debug Executive to Function Area Reserved for Debug Executive
4.7 k 4.7 k
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.
DS51766B-page 23
2.8
2.9
DS51766B-page 24
3.2
3.3
3.4
DS51766B-page 25
3.5
Communications Cable
From Target
2 USB/Power
From PC
3.6
3.6.1
For production devices, the debugger may be connected directly to the target board. The device on the target board must have built-in debug circuitry in order for the MPLAB ICD 3 in-circuit debugger to perform emulation with it. Consult the device data sheet to see if the device has the needed debug circuitry, i.e., it should have a Background Debugger Enable Configuration bit. 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.4 Debugger To Target Communication, Standard ICSP Device Communication.
DS51766B-page 26
Installation
3.6.2 Using ICE Devices
For ICE devices, an ICE header board is required. The header board contains the hardware necessary to emulate a specific device or family of devices. For more information on ICE headers, see the Header Board Specification (DS51292). 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.4 Debugger To Target Communication, Standard ICSP Device Communication.
3.6.3
There are a couple of configurations for powering MPLAB ICD 3 and the target. These are configuration essentials: When using the USB connection, MPLAB ICD 3 can be powered from the PC but it can only provide a limited amount of current, up to 100 mA, at VDD from 3-5V to a small target board. The desired method is for the target to provide VDD as it can provide a wider voltage range from 2-5V. The additional benefit is that plug-and-play target detection facility is inherited, i.e., MPLAB IDE will let you know in the Output window when it has detected the target and has detected the device. Note: The target voltage is only used for powering up the drivers for the ICSP interface; the target voltage does not power-up the MPLAB ICD 3. The MPLAB ICD 3 system power is derived strictly from the USB port.
If you have not already done so, connect the MPLAB ICD 3 to the target using the appropriate cables (see Section 3.5 Connecting the Target). Then power the target. If you are powering the target through the MPLAB ICD 3, see Section 9.5.7 Settings Dialog, Power Tab for instructions.
3.7
DS51766B-page 27
DS51766B-page 28
4.2
DS51766B-page 29
4.4
4.5
4.6
DS51766B-page 30
General Setup
4.7 SETTING THE DEBUGGER AS THE DEBUGGER OR PROGRAMMER
Select Debugger>Select Tool>MPLAB ICD 3 to choose the MPLAB ICD 3 in-circuit debugger as the debug tool. The Debugger menu and MPLAB IDE toolbar will change to display debug options once the tool is selected. Also, the Output window will open and messages concerning MPLAB ICD 3 status and communications will be displayed on the MPLAB ICD 3 tab. For more information, see Section 9.2 Debugging Functions and Section 9.3 Debugging Dialogs/Windows. Select Programmer>Select Programmer>MPLAB ICD 3 to choose the MPLAB ICD 3 in-circuit debugger as the programmer tool. The Programmer menu and MPLAB IDE toolbar will change to display programmer options once the tool is selected. Also, the Output window will open and messages concerning ICE status and communications will be displayed on the MPLAB ICD 3 tab. For more information, see Section 9.4 Programming Functions. Select Debugger>Settings or Programmer>Settings to open the Settings dialog (Section 9.5 Settings Dialog) and set up options as needed. If errors occur, see: Chapter 7. Error Messages Chapter 6. Frequently Asked Questions (FAQs) Section A.7 ICD 3 Test Interface Board
4.8
TABLE 4-1:
Needed Hardware
Debugger>Select Tool>MPLAB ICD 3 Programmer>Select Programmer>MPLAB ICD 3 Debug from the Build Configuration toolbar. Release from the Build Configuration toolbar. Use the standard linker script, e.g., 18F452.lkr.
Linker script (optional) Use the i version of the linker script, See MPLAB IDE documentation to e.g., 18F452i.lkr. determine if you need to add a linker script to your project. Program operation Programs application code into the device. Depending on the selections on the Program tab of the Settings dialog, this can be any combination of program memory, EEPROM memory, Configuration bits, or ID memory. In addition, a small debug executive is placed in program memory and other debug resources are reserved. N/A
Programs application code into the device. Depending on the selections on the Program tab of the Settings dialog, this can be any combination of program memory, EEPROM memory, Configuration bits, or ID memory.
SQTP
Use the MPLAB PM3 to generate the SQTP file. Then use the debugger to program the device. N/A.
DS51766B-page 31
DS51766B-page 32
DS51766B-page 33
5.3
DS51766B-page 34
Tutorial
counter.c
/***************************************************************************** * MPLAB ICD 3 In-Circuit Debugger Tutorial * Counting program * ***************************************************************************** * Demo Board: Explorer 16 * Processor: PIC24FJ128GA010 * Compiler: MPLAB C30 * Linker: MPLAB LINK30 * Company: Microchip Technology Incorporated * *****************************************************************************/ #include "p24FJ128GA010.h" // Set up configuration bits _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2) _CONFIG2( FCKSM_CSDCMD & OSCIOFNC_ON & POSCMOD_HS & FNOSC_PRI ) void TimerInit(void); unsigned char TimerIsOverflowEvent(void); // Set up user-defined variables #define INIT_COUNT 0 unsigned int counter; int main(void) { // Set up PortA IOs as digital output AD1PCFG = 0xffff; TRISA = 0x0000; // Set up Timer1 TimerInit(); // Initialize variables counter = INIT_COUNT; while (1) { // Wait for Timer1 overflow if (TimerIsOverflowEvent()){ counter++; //increment counter PORTA = counter; //display on port LEDs }// End of if... }// End of while loop... }// End of main()...
DS51766B-page 35
DS51766B-page 36
Tutorial
IFS0bits.T1IF = 0; TMR1 = 0; return(1); } return(0); } /********************************************************************* * EOF ********************************************************************/
5.4
4. Proceed to the next dialog (Figure 5-3) of the wizard to give a name and location to your project. You may Browse to find a location.
DS51766B-page 37
5. Proceed to the next dialog (Figure 5-4) of the wizard where project files can be added. Files can also be added later if something is missed. For this example, browse to your project directory to find both files. Click on counter.c to highlight it and then click on ADD>> to add it to the right pane. Click on timer.c to highlight it and then click on ADD>> to add it to the right pane. Leave the A next to the file name. For more information on what this and other letters mean, click the Help button on the dialog. FIGURE 5-4: PROJECT WIZARD ADD FILES
6. Proceed to the Summary screen. If you have made any errors, click <Back to return to a previous wizard dialog. If everything is correct, click Finish.
DS51766B-page 38
Tutorial
5.5 VIEWING THE PROJECT
After exiting the wizard, the MPLAB IDE desktop will again be visible. If the Project window is not open, select View>Project to see the Project window (Figure 5-5). FIGURE 5-5: PROJECT WINDOW
Additional files can be added to the project using the Project window. Right click on any line in the Project window tree to pop up a menu with additional options for adding and removing files. Note: Although the header file p24FJ128GA010.h and a linker script file are used in the project, you do not need to add them to the project; MPLAB IDE will find them for you.
DS51766B-page 39
5.6.1
Configuration Bits
In this tutorial, the relevant device Configuration bits are set in the counter.c code using the _CONFIG1 and _CONFIG2 directives. For information on the function of these PIC24FJ128GA010 Configuration register bits, see the PIC24FJ128GA Family Data Sheet (DS39747). Configuration bits also may be set by selecting Configure>Configuration Bits and unchecking Configuration bits set in code (see Figure 5-6). Do not change any values for this tutorial. FIGURE 5-6: CONFIGURATION BITS WINDOW
5.6.2
To select MPLAB ICD 3 in-circuit debugger as a debugger, select Debugger>Select Tool>ICD 3. Then: 1. The Output window will open to display connection information. Depending on the version of MPLAB IDE or the device selected, a message box may appear indicating that the firmware needs to be updated. Select OK in the message box to allow MPLAB IDE to install the new firmware. Allow several seconds for the firmware to update. Also, since different MPLAB ICD 3 firmware is used for different families of devices, this message box may appear when switching to a different device. 2. The Output window will display information about the firmware update and will show when the MPLAB ICD 3 is connected to the target. 3. The Debugger menu will show available debugger debug options. 4. A Debug toolbar will appear. Mouse over a button to see a pop-up of its function.
DS51766B-page 40
Tutorial
5.6.3 Programming Options
To set program options, select Debugger>Settings and click on the Program Memory tab (see Figure 5-7). FIGURE 5-7: DEBUGGER PROGRAM MEMORY TAB
Here you may allow the debugger to automatically choose the programming ranges (recommended) or you may select ranges manually. The Memories section should have Program checked, and EEPROM and ID unchecked. When using the MPLAB ICD 3 in-circuit debugger as a debugger, Configuration bits will always be programmed and the Configuration box will be checked and grayed out. For the PIC24FJ devices, all memory will be erased each time the chip is programmed. Therefore, in the Program Options section, Erase all before Program will have no effect. The Program Memory addresses (Start and End address) set the range of program memory that will be read, programmed or verified. When debugging code, you will frequently repeat the edit, rebuild, reprogram and run sequence. To automate this, there are check boxes Program after successful build and Run after successful program. Leave these unchecked for now.
5.7
DS51766B-page 41
FIGURE 5-8:
FIGURE 5-9:
DS51766B-page 42
Tutorial
5.8 SETTING UP THE DEMO BOARD
Before beginning to debug, make sure the Explorer 16 Demo Board is set up properly. For more information, see the Explorer 16 Development Board Users Guide (DS51589). Settings for this tutorial should be as follows: PIC24FJ128GA010 PIM (Plug-In Module) plugged into the board. S2: PIM selected; PIC selection for devices soldered onto the board. J7: PIC24 selected; the debugger will communicate directly with the PIC24FJ128GA010 and not the on-board PIC18LF4550 USB device. JP2: LEDs have been enabled by connecting Jumper 2. D1 on: Power being supplied to board.
5.9
During programming, the ICD 3 tab of the Output dialog shows the current phase of operation. When programming is complete, the dialog should look similar to Figure 5-10. FIGURE 5-10: OUTPUT WINDOW MPLAB ICD 3 TAB
Note:
If you have trouble programming your device or communicating with the debugger, unplug the Explorer 16 board and use the self-test board (Section A.7 ICD 3 Test Interface Board) to verify communications. For additional help, see Chapter 6. Frequently Asked Questions (FAQs).
DS51766B-page 43
Begin in Real-Time mode: 1. Open the source files counter.c and timer.c (double click on the file names in the Project window or use File>Open). 2. Select Debugger>Run (or click the Run toolbar button). 3. Observe the LEDs. They will be counting up in binary. 4. Select Debugger>Halt (or click the Halt toolbar button) to stop the program execution. 5. When the debugger halts, one of the open source code windows will pop to the front and a green arrow will indicate where the program halted. To use Step mode: 1. Select Debugger>Step Into (or click the Step Into toolbar button) to execute one instruction and then halt. The green arrow in the code listing will move accordingly. 2. Repeat as needed. The step functions Step Over and Step Out are used with functions and discussed in the MPLAB IDE documentation.
5.11
DS51766B-page 44
Tutorial
5.11.1 Choosing a Breakpoint Type
The device used in this tutorial has the capability of using either hardware or software breakpoints: Hardware Breakpoint An event whose execution will cause a Halt as a result of a Program Counter match and special logic inside the device. Software Breakpoint An address where execution of the firmware will halt. Usually achieved by a special break instruction. To set breakpoint options, select Debugger>Settings and click on the Configuration tab. Select the type of breakpoint that best suits your application needs. For this tutorial, we will begin using the default breakpoint type (hardware breakpoints).
5.11.2
To set a single hardware breakpoint: 1. Select Debugger>Reset>Processor Reset (or click the Reset toolbar button) to reset the example program. 2. Highlight or place the cursor on the following line of code from counter.c: counter++; //increment counter 3. Double click on the line, or right click on the line and then select Set Breakpoint from the shortcut menu. This line is now marked as a breakpoint (B in red stop sign) as shown in Figure 5-11. FIGURE 5-11: SET BREAKPOINT
4. Select Debugger>Run (or click the Run toolbar button) to run the program once again in Real-Time mode. The program will halt at the line marked by the breakpoint, but now there will be a green arrow over the breakpoint symbol (see Figure 5-12).
DS51766B-page 45
5. Open a new Watch window to watch the counter variable change value as the program executes. Select View>Watch. The Watch dialog opens with the Watch 1 tab selected. Select counter from the list next to Add Symbol, and then click the button. counter is added to the Watch window. Select PORTA from the list next to Add SFR, and then click the button. PORTA is added to the Watch window. The selected symbols should now be visible in the Watch window as shown in Figure 5-13. FIGURE 5-13: WATCH WINDOW
6. Select Debugger>Run (or click the Run toolbar button) to run the program once again. The program will halt at the breakpoint and you will notice that the value of both variables has incremented by 1. 7. Run again as desired to see the values increase. When done, use Debugger>Reset>Processor Reset (or click the Reset toolbar button) to reset the processor.
5.11.3
To set multiple breakpoints, either set numerous single breakpoints as specified in the previous section, or use the Breakpoints dialog (see Section 9.3.1 Breakpoints Dialog). The Breakpoints dialog also allows you to control breakpoint interaction such as sequenced or ANDed breakpoints. Note: If you exceed the maximum allowed number of breakpoints for your device, MPLAB IDE will warn you. You can then enable software breakpoints.
For this example, place a breakpoint at the counter++ source line in the while loop. 1. Select Debugger>Breakpoints to open the Breakpoints dialog. The breakpoint set in the previous section will be displayed in this dialog. Click the Add Breakpoint button to add another breakpoint. 2. On the Program Memory tab of the Set Breakpoint dialog, enter 2e6 as the hex address and click OK. (See Figure 5-14.)
2010 Microchip Technology Inc.
DS51766B-page 46
Tutorial
FIGURE 5-14: SET BREAKPOINTS DIALOG
The additional breakpoint will appear below the previous breakpoint in the Breakpoints dialog (Figure 5-15) and also as a breakpoint symbol next to the following line of code: PORTA = counter; //display on port LEDs The breakpoint symbol is yellow in this case because it was set based on an address. FIGURE 5-15: TWO BREAKPOINTS
3. Run the program to see it halt at the first breakpoint. The values in the Watch window will not change. Then run again to see it stop at the second breakpoint. (The program may skid past this breakpoint.) Now the values in the Watch window will change (Figure 5-16).
DS51766B-page 47
5.11.4
ANDed Breakpoints
ANDed breakpoints allow you to qualify two events at exactly the same bus cycle. In some cases, you may need to qualify an instruction execution cycle with its data counterpart, such as a write to a memory location. In the example in Figure 5-17, counter is written once outside of the while loop, but you may want to qualify it with a write inside the while loop when the counter variable has a specific value or simply when it occurs within the loop. To set a breakpoint on the variable counter and to qualify it as an ANDed breakpoint, first double click on the counter++ as shown in Figure 5-17. This places a program memory breakpoint at the program address corresponding to the C statement counter++. FIGURE 5-17: SET ONE BREAKPOINT AT COUNTER VARIABLE
DS51766B-page 48
Tutorial
Then, add the second data breakpoint for the counter variable at the register file address 0x850 (see Figure 5-18). Notice that the value 0x850 corresponds to the counter variable. FIGURE 5-18: SET SECOND BREAKPOINT
From the Available Breakpoints on the left, select and click Add for each one so it shows up in the ANDed Breakpoints box on the right side (see Figure 5-19). FIGURE 5-19: ANDed BREAKPOINTS
Reset and Run the program. Notice that the breakpoint did not occur. Why? Because for ANDed breakpoints to trigger they must occur at the same time. Modify the program memory address from 0x2de to 0x2e2 (see Figure 5-20) to coincide with the write to the register at address 0x850 as shown in Figure 5-21.
DS51766B-page 49
FIGURE 5-21:
Verify that the new address is reflected in the ANDed breakpoint dialog (see Figure 5-22). FIGURE 5-22: VERIFY ANDed BREAKPOINT
DS51766B-page 50
Tutorial
5.11.5 Sequenced Breakpoints
Sequenced breakpoints can be specified to occur in a desired sequence. There can be up to four sequences specified for some devices. The number of breakpoints is device dependent. For a device that has a total of four breakpoints, the first three are the qualifiers and the last one is the trigger. The trigger is the final breakpoint and halts the CPU. In this example, double click on the counter and counter++ as shown in Figure 5-23. FIGURE 5-23: SET BREAKPOINTS AT COUNTER AND COUNTER++ VARIABLES
DS51766B-page 51
Click Sequenced Breakpoints to open the Sequenced Breakpoints dialog (Figure 5-25). Select each item from the Available Breakpoints box and click Add to add each one to the Sequences on the right. Note: The sequence execution is from the bottom to the top, where the trigger or breakpoint is at the top and the qualifier(s) are at the bottom. SEQUENCED BREAKPOINTS DIALOG
FIGURE 5-25:
See Note for explanation of sequence execution. Reset and Run the program. The program will stop at the second breakpoint defined in the sequence. The first qualifier at line number 34 essentially arms the breakpoint logic so when the breakpoint is executed at line number 39, it halts the CPU. See Figure 5-26.
DS51766B-page 52
Tutorial
FIGURE 5-26: SEQUENCED BREAKPOINTS
5.11.6
To determine the time between the breakpoints, use the Stopwatch. 1. Click Stopwatch (on the Breakpoints dialog) to open the Stopwatch dialog (Figure 5-27). FIGURE 5-27: STOPWATCH DIALOG
2. Under Start Condition, select the first breakpoint from the list. Then uncheck Start condition will cause the target device to halt. 3. Under Stop Condition, select the second breakpoint from the list. Then check Stop condition will cause the target device to halt. 4. Check Reset stopwatch on run. See Figure 5-28. 5. Click OK.
DS51766B-page 53
6. Run the program until it halts. In the Output window, on the ICD 3 tab, the number of cycles between the two instructions should be shown as: Stopwatch cycle count = 4(decimal) 7. Clear both breakpoints from the code by deleting them from the Breakpoints dialog, double clicking on each line to remove them, or right clicking on each line and selecting Remove Breakpoint. You can also right click and select Breakpoints>Remove All Breakpoints to remove both at once.
5.11.7
To change the breakpoint type from hardware to software: Select Debugger>Settings and click on the Configuration tab. Click the radio button next to Use Software Breakpoints. Click OK. You will now use software breakpoints instead of the hardware breakpoints used previously. Note: Using software breakpoints for debug impacts device endurance. Therefore, it is recommended that devices used in this manner not be used as production parts.
1. To set a single software breakpoint, follow the instructions in Section 5.11.2 Setting a Single Hardware Breakpoint. - When you set a software breakpoint, you will see the following in the Output window: Programming software breakpoint(s)... Software breakpoint(s) set. - If you have already set a hardware breakpoint in this tutorial, the variables will already be added to the Watch window for use with the software breakpoint. 2. To set multiple software breakpoints, follow the instructions in Section 5.11.3 Setting Multiple Hardware Breakpoints. - There is no breakpoint skidding with software breakpoints, i.e., the program halts on the breakpoint. This may affect how you see values change in the Watch window.
DS51766B-page 54
Tutorial
- There is a maximum number of breakpoints with software breakpoints, i.e, although this tutorial only uses two, the number of software breakpoints is 999. 3. The stopwatch is meant to be used with hardware breakpoints. However, you can use the stopwatch with software breakpoints, but they will be converted to hardware breakpoints as you select them. In the Output window, you will see: Converting breakpoint types... Breakpoint type conversion complete. Follow the steps as specified in Section 5.11.6 Using the Stopwatch with Breakpoints. 4. Set the breakpoints to hardware again for the remainder of the tutorial. Select Debugger>Settings, click on the Configuration tab, click the radio button next to Use Hardware Breakpoints and then click OK.
5.12
DS51766B-page 55
DS51766B-page 56
DS51766B-page 57
DS51766B-page 58
MPLAB ICD 3 IN-CIRCUIT DEBUGGER USERS GUIDE Chapter 6. Frequently Asked Questions (FAQs)
6.1 INTRODUCTION
Look here for answers to frequently asked questions about the MPLAB ICD 3 in-circuit debugger system. How Does It Work Whats Wrong
6.2
DS51766B-page 59
6.3
WHATS WRONG
My PC went into Power-Down/Hibernate mode, and now my debugger wont work. What happened? When using the debugger for prolonged periods of time, and especially as a debugger, be sure to disable the Hibernate mode in the Power Options Dialog window of your PCs operating system. Go to the Hibernate tab and clear or uncheck the Enable hibernation check box. This will ensure that all communication is maintained across all the USB subsystem components. I set my peripheral to NOT freeze on Halt, but it is suddenly freezing. What's going on? For dsPIC30F/33F and PIC24F/H devices, a reserved bit in the peripheral control register (usually either bit 14 or 5) is used as a Freeze bit by the debugger. If you have performed a write to the entire register, you may have overwritten this bit. (The bit is user-accessible in Debug mode.) To avoid this problem, write only to the bits you wish to change for your application (BTS, BTC) instead of to the entire register (MOV).
DS51766B-page 60
DS51766B-page 61
DS51766B-page 62
7.2
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. ICD3Err0001: Failed while writing to program memory. ICD3Err0002: Failed while writing to EEPROM. ICD3Err0003: Failed while writing to configuration memory. See Section 7.4.1 Read/Write Error Actions. ICD3Err0005: ICD 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. ICD3Err0006: Failed while writing to user ID memory. ICD3Err0007: Failed while reading program memory. ICD3Err0008: Failed while reading EEPROM. ICD3Err0009: Failed while reading configuration memory. ICD3Err0010: Failed while reading user ID memory. See Section 7.4.1 Read/Write Error Actions. ICD3Err0011: Bulk erase failed. See Section 7.4.1 Read/Write Error Actions. If these do not work, try another device.
DS51766B-page 63
If this does not work, see Section 7.4.4 Corrupted Installation Actions. ICD3Err0013: NMMR register write failed. ICD3Err0014: File register write failed. See Section 7.4.2 Debugger-to-Target Communication Error Actions. ICD3Err0015: Data transfer was unsuccessful. %d byte(s) expected, %d byte(s) transferred. See Section 7.4.3 Debugger-to-PC Communication Error Actions. ICD3Err0016: Cannot transmit. ICD 3 not found. The debugger is not connected to the PC. ICD3Err0017: File register read failed. ICD3Err0018: NMMR register read failed. ICD3Err0019: Failed while reading emulation registers. ICD3Err0020: Failed while writing emulation registers. See Section 7.4.2 Debugger-to-Target Communication Error Actions. ICD3Err0021: Command not echoed properly. Sent %x, received %x. ICD3Err0022: Failed to get ICD 3 version information. ICD3Err0023: Download FPGA failed. ICD3Err0024: Download RS failed. ICD3Err0025: Download AP failed. See Section 7.4.3 Debugger-to-PC Communication Error Actions. ICD3Err0026: Download program exec failed. If you receive this error while attempting to program from the Debugger menu: 1. 2. 3. 4. Deselect the debugger as the debug tool. Close your project and then close MPLAB IDE. Restart MPLAB IDE and re-open your project. Reselect the debugger as your debug tool and attempt to program your target device again.
If this does not work, see Section 7.4.4 Corrupted Installation Actions. ICD3Err0027: Bulk transfer failed due to invalid checksum See Section 7.4.3 Debugger-to-PC Communication Error Actions. Also, ensure that the cables used are the correct length. ICD3Err0028: Download device database failed If you receive this error: 1. Try downloading again. It may be a one-time error. Allow sufficient time for the download to complete and do not disconnect the MPLAB ICD 3 during the download. 2. Try manually downloading. Select Debugger>Settings, Configuration tab, and click Manual Download. Select the highest number .jam file and click Open.
DS51766B-page 64
Error Messages
ICD3Err0029: Communication failure. Unexpected command echo response %x received from ICD 3. See Section 7.4.3 Debugger-to-PC Communication Error Actions. ICD3Err0030: Unable to read/find firmware File %s. If the Hex file exists: Reconnect and try again. If this does not work, the file may be corrupted. Reinstall MPLAB IDE. If the Hex file does not exist: Reinstall MPLAB IDE. ICD3Err0031: Failed to get PC. ICD3Err0032: Failed to set PC. See Section 7.4.2 Debugger-to-Target Communication Error Actions. ICD3Err0033: %d bytes expected, %d bytes received. See Section 7.4.3 Debugger-to-PC Communication Error Actions. Use the ICD 3 Test Interface Board to verify your MPLAB ICD 3 is functioning properly. See Section A.7 ICD 3 Test Interface Board. ICD3Err0034: This version of MPLAB IDE does not support hardware revision %06x. Please upgrade to the latest version of MPLAB IDE before continuing. If you receive this error, try manually downloading the latest version of MPLAB IDE. Keep the MPLAB ICD 3 connected to the PC and select Debugger>Settings, Configuration tab, and click Manual Download. In the Update MPLAB ICD 3 window, select the highest number .jam file and click Open. Allow sufficient time for the download to complete. Check the Output window for the completion status. ICD3Err0035: Failed to get Device ID. If you experience persistent problems communicating, the ICD 3 test interface can be used to help diagnose the problem. See Section 7.4.1 Read/Write Error Actions and Section A.7 ICD 3 Test Interface Board. ICD3Err0036: MPLAB IDE has lost communication with ICD 3. See Section 7.4.3 Debugger-to-PC Communication Error Actions. ICD3Err0037: Timed out waiting for response from ICD 3. ICD3Err0038: Failed to initialize ICD 3. ICD3Err0039: ICD 3 self-test failed. For this error, the debugger is not responding: 1. Unplug and plug in the debugger. 2. Reconnect to the debugger in MPLAB IDE. 3. If the problem persists contact Microchip. ICD3Err0040: The target device is not ready for debugging. Please check your configuration bit settings and program the device before proceeding. You will receive this message when you have not programmed your device for the first time and try to Run. If you receive this message after this, or immediately after programming your device, please refer to Section 7.4.6 Debug Failure Actions. Use the ICD 3 Test Interface Board to verify your MPLAB ICD 3 is functioning properly. See Section A.7 ICD 3 Test Interface Board.
DS51766B-page 65
DS51766B-page 66
Error Messages
ICD3Err0067: Failed to set/clear software breakpoint. Reprogram and try again. ICD3Err0068: Failed while writing to boot Flash memory. ICD3Err0069: Failed while reading boot Flash memory. ICD3Err0070: Failed while writing peripheral memory. ICD3Err0071: Failed while reading peripheral memory. See Section 7.4.1 Read/Write Error Actions. ICD3Err0072: Unable to send freeze peripheral information. See Section 7.4.3 Debugger-to-PC Communication Error Actions. ICD3Err0073: Device is code-protected. The device on which you are attempting to operate (read, program, blank check or verify) is code-protected, i.e., the code cannot be read or modified. Check your Configuration bits setting for code protection. To disable code protection, set or clear the appropriate Configuration bits in code or in the Configuration Bits window (Configure>Configuration Bits), according to the device data sheet. Then erase and reprogram the entire device. ICD3Err0082: Test interface LVP control line failure. ICD3Err0083: Test interface MCLR level failure. See Section A.7 ICD 3 Test Interface Board.
7.3
INFORMATION MESSAGES
ICD3Info0001: ICD3 is functioning properly. If you are still having problems with your target circuit please check the Target Board Considerations section of the online help. See Section A.8 Target Board Considerations.
7.4
7.4.1
If you receive a read or write error: 1. Did you hit Abort? This may produce read/write errors. 2. Try the action again. It may be a one-time error. 3. Ensure that the target is powered and at the correct voltage levels for the device. See the device data sheet for required device voltage levels. 4. Ensure that the debugger-to-target connection is correct (PGC and PGD are connected.) 5. For write failures, ensure that Erase all before Program is checked on the Program Memory tab of the Settings dialog. 6. Ensure that the cables used are of the correct length.
DS51766B-page 67
7.4.3
The MPLAB ICD 3 in-circuit debugger and MPLAB IDE are out-of-sync with each other. 1. Use the ICD 3 Test Interface Board to verify your MPLAB ICD 3 is functioning properly. See Section A.7 ICD 3 Test Interface Board. 2. Unplug and then plug in the debugger. 3. Reconnect to the debugger. 4. Try the operation again. It is possible the error was a one time glitch. 5. The version of MPLAB IDE installed may be incorrect for the version of firmware loaded on the MPLAB ICD 3 in-circuit debugger. Follow the steps outlined in Section 7.4.4 Corrupted Installation Actions.
7.4.4
The problem is most likely caused by a incomplete or corrupted installation of MPLAB IDE. 1. 2. 3. 4. Uninstall all versions of MPLAB IDE from the PC. Reinstall the desired MPLAB IDE version. Force a manual download of the firmware. If the problem persists contact Microchip.
DS51766B-page 68
Error Messages
7.4.5 USB Port Communication Error Actions
The problem is most likely caused by a faulty or non-existent communications port. 1. Reconnect to the MPLAB ICD 3 in-circuit debugger 2. Make sure the debugger is physically connected to the PC on the appropriate USB port. 3. Make sure the appropriate USB port has been selected in the debugger Settings. 4. Make sure the USB port is not in use by another device. 5. If using a USB hub, make sure it is powered. 6. Make sure the USB drivers are loaded.
7.4.6
The MPLAB ICD 3 in-circuit debugger was unable to perform a debugging operation. There are numerous reasons why this might occur:
DS51766B-page 69
7.4.7
Internal errors are unexpected and should not happen. They are primarily used for internal Microchip development. The most likely cause is a corrupted installation (Section 7.4.4 Corrupted Installation Actions). Another likely cause is exhausted system resources. 1. Try rebooting your system to free up memory. 2. Make sure you have a reasonable amount of free space on your hard drive (and that it is not overly fragmented.) If the problem persists contact Microchip.
DS51766B-page 70
DS51766B-page 71
DS51766B-page 72
MPLAB ICD 3 IN-CIRCUIT DEBUGGER USERS GUIDE Chapter 8. Basic Debug Functions
8.1 INTRODUCTION
Basic MPLAB ICD 3 in-circuit debugger functions of breakpoints and stopwatch are discussed.
8.2
To set a breakpoint in code, do one of the following: Double click or right click on a line of code to set up an individual breakpoint. Select Debugger>Breakpoints to open the Breakpoints dialog and set up multiple breakpoints and breakpoint conditions. See Section 9.3.1 Breakpoints Dialog for more information. To determine the time between the breakpoints, use the stopwatch: 1. Determine whether your device supports stopwatch use. See the online Help file, Device and Feature Support. 2. Open the Breakpoints dialog (Debugger>Breakpoints). 3. Click Stopwatch on the Breakpoints dialog to open the Stopwatch dialog. 4. Under Start Condition, select a breakpoint from the drop-down list. Also decide whether or not to select Start condition will cause the target device to halt. 5. Under Stop Condition, select another breakpoint from the drop-down list. Also decide whether or not to select Stop condition will cause the target device to halt. 6. Decide if there will be a Reset stopwatch on run. 7. Click OK.
DS51766B-page 73
DS51766B-page 74
MPLAB ICD 3 IN-CIRCUIT DEBUGGER USERS GUIDE Chapter 9. Debugger Function Summary
9.1 INTRODUCTION
A summary of the MPLAB ICD 3 in-circuit debugger functions on menus, in windows and on dialogs is listed here. Debugging Functions Debugging Dialogs/Windows Programming Functions Settings Dialog
9.2
DEBUGGING FUNCTIONS
When you select the MPLAB ICD 3 from the Debugger menu, the following items will be added to the MPLAB IDE functions: Debugger Menu additional options are added to the drop-down menu Right Mouse Button Debugger Menu additional options are added to this menu Toolbars/Status Bar a toolbar appears below the menu bar; additional information appears in the status bar
9.2.1
Run F9
Debugger Menu
Execute program code until a breakpoint is encountered or until Halt is selected. Execution starts at the current Program Counter (as displayed in the status bar). The current Program Counter location is also represented as a pointer in the Program Memory window. While the program is running, several other functions are disabled. Animate Animate causes the debugger to actually execute single steps while running, updating the values of the registers as it runs. Animate runs slower than the Run function, but allows you to view changing register values in the Special Function Register window or in the Watch window. To Halt Animate, use the menu option Debugger>Halt, the toolbar Halt or <F5>. Halt F5 Halt (stop) the execution of program code. When you click Halt, status information is updated. Step Into F7 Single step through program code. For assembly code, this command executes one instruction (single or multiple cycle instructions) and then halts. After execution of one instruction, all the windows are updated.
DS51766B-page 75
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 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 9.3.1 Breakpoints Dialog). 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. Debug Read Reads program memory using the debug executive. 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 MPLAB ICD 3 in-circuit debugger. The progress of this connection is shown on the ICD 3 tab of the Output dialog. Settings Open the Programmer dialog (see Section 9.5 Settings Dialog). Set up program and firmware options.
DS51766B-page 76
9.2.3
Toolbars/Status Bar
When the MPLAB ICD 3 in-circuit debugger is selected as a debugger, these toolbars are displayed in MPLAB IDE: Basic debug toolbar (Run, Halt, Animate, Step Into, Step Over, Step Out, Reset). Simple program toolbar (Read, Program, Erase Flash Device). The selected debug tool (MPLAB ICD 3), as well as other development information, is displayed in the status bar on the bottom of the MPLAB IDE desktop. Refer to the MPLAB IDE online help for information on the contents of the status bar.
DS51766B-page 77
9.3.1
Breakpoints Dialog
To set up breakpoints, select Debugger>Breakpoints. Set up different types of breakpoints in this dialog. Click on Add Breakpoint to add breakpoints to the dialog window. Depending on your selected device, there may be other buttons for more advanced breakpoint options. 9.3.1.1 BREAKPOINT DIALOG WINDOW
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
DS51766B-page 78
TABLE 9-2:
Control Add Breakpoint Stopwatch
Set up a sequence until break Section 9.3.5 Sequenced Breakpoints Dialog Set up ANDed condition until break Section 9.3.6 ANDed Breakpoints Dialog
9.3.2
Click Add Breakpoint in the Breakpoints Dialog to display this dialog. Select a breakpoint for the Breakpoints dialog here. 9.3.2.1 PROGRAM MEMORY TAB
Pass Count
DS51766B-page 79
Pass Count
9.3.3
Stopwatch Dialog
Click Stopwatch in the Breakpoints Dialog to display this dialog. The stopwatch allows timing from one breakpoint/trigger condition to the next. The stopwatch value is in decimal. TABLE 9-5:
Control Start Condition
STOPWATCH SETUP
Function Select an available breakpoint or trigger condition to start the stopwatch. Available breakpoints/triggers are those previously added to the breakpoint dialog. Select None to clear the start condition. To halt the program run on this condition, check the check box next to Start condition will cause the target device to halt. Select an available breakpoint or trigger condition to stop the stopwatch. Available breakpoints/triggers are those previously added to the breakpoint dialog. Select None to clear the stop condition. To halt the program run on this condition, check the check box next to Stop condition will cause the target device to halt. Reset the stopwatch values to zero every time the program is run.
Stop Condition
DS51766B-page 80
9.3.5
Click Sequenced Breakpoints in the Breakpoints Dialog to display this dialog. Set up a sequential occurrence of breakpoints. Sequence execution of breakpoints is bottom-up; the last breakpoint in the sequence occurs first. To add a breakpoint to a sequence: Select a breakpoint from the list of Available Breakpoints. Available breakpoints/triggers are those previously added to the breakpoint dialog. Select a sequence for the list of Sequences. Click Add. To change the order of breakpoints in a sequence, drag-and-drop the breakpoint in the Sequences list. To remove a breakpoint from a sequence: Select the breakpoint in the Sequences list. Click Remove.
9.3.6
Click ANDed Breakpoints in the Breakpoints Dialog to display this dialog. Set up an ANDed condition for breaking, i.e., breakpoint 1 AND breakpoint 2 must occur at the same time before a program Halt. This can only be accomplished if a data breakpoint and a program memory breakpoint occur at the same time. To add a breakpoint to the AND condition: Select a breakpoint from the list of Available Breakpoints. Available breakpoints/triggers are those previously added to the breakpoint dialog. Click Add. To remove a breakpoint from a sequence: Select the breakpoint in the ANDed Breakpoints list. Click Remove. Close Close this window. Find Opens the Find dialog. In the Find What field, enter a string of text you want to find, or select text from the drop-down list. You can also select text in the edit window or place the cursor over a word you want to search for, before you open the Find dialog. In the Find dialog you may select any of the available options and the direction you want to search. Up searches backward from the insertion point, Down searches forward.
DS51766B-page 81
DS51766B-page 82
This window allows you to interact with a running application using the Application Input/Output feature supported on some devices. Using this feature, data may be sent serially to and from the target application and, during runtime, over the same PGC/PGD lines used for debugging. Data written to the APPOUT register will be displayed to the window, while user input will be sent to the target application and available in the APPIN register. For more on how to set up the application, see Section 9.3.7.3 Application Code Using AppIn/AppOut below. TABLE 9-6:
Control Capture
INPUT/OUTPUT WINDOW
Function Capture Output display data to a text file. Off: Output display capture off. On: Output display capture on. Enter the path and name of the capture file, or Browse to it. Data sent to the capture file is always appended to it. User Input commands will appear in the file in double brackets, i.e., [[Send more data]]. Note: You must close this window to see appended information appear in the file.
Clear the data currently in the Output display. Currently unused (dedicated Application In/Out). Specify the Output or Input data format: Text, 8-bit Hex, 16-bit Hex or 32-bit Hex. Output data from the target is displayed here. Also, User Input is displayed in bold after it has been successfully sent. Right-click in the display to open a menu. Type in commands to be sent to the target application. Press Enter to send. Right-click in the text box to open a menu. Note: Although the User Input text box may hold more than 4 bytes of information, the debug tool will only send 4 bytes at a time to the target. Therefore the target application may need to check the application input register more than once to receive all data sent.
User Input
9.3.7.1
Perform copying, clearing and display formatting on the data in the Output display. Copy Selection Select an area of text with the mouse in the Output display and then use this command to copy it to the PC clipboard. Then you may Paste it into Textpad or another application. Clear removes the data currently in the Output display. Display with ASCII Display the ASCII representation (if any) of the values in the hex data to the right of the data. Display with Index Display a relative byte index of the hex data to the left of the
DS51766B-page 83
Perform general editing functions on the text in the User Input text box. Undo Removes previous typing. Cut Remove the selected/highlighted text and place on the PC clipboard. Copy Place the selected/highlighted text on the PC clipboard Paste Insert any text on the PC clipboard at the current cursor position. Delete Remove the selected/highlighted text. Select All Select/highlight all text in this text box. APPLICATION CODE USING APPIN/APPOUT
9.3.7.3
Use the device-specific header file when building your application to use the macros assigned in the header (per Example 9-1). Alternatively, the PIC32 MCU library has printf() and scanf() functions for use with the Application In/Out feature. Refer to the PIC32 Debug-Support Library chapter in 32-Bit Language Tools Libraries (DS51685). EXAMPLE 9-1: APPLICATION IN/OUT MACRO USAGE
The application code reads the application input register and writes out a padded value of the input to the application output register.
while(1) { if(_DDPSTATbits.APIFUL) // APPI is full? { val = _APPI; // Read User Input for(i=0; i<4; i++) { while(_DDPSTATbits.APOFUL); // APPO is full? oval = val&0xFF; if(oval < 0x20) oval = 0x20; oval |= 0x20202000; _APPO = oval; // Send to MPLAB IDE val >>= 8; } } }
DS51766B-page 84
9.4.1
Program
Programmer Menu
Program specified memory areas: program memory, Configuration bits, ID locations and/or EEPROM data. See the Settings dialog for programming options. Verify Verify programming of specified memory areas: program memory, Configuration bits, ID locations and/or EEPROM data. Read Read specified memory areas: program memory, Configuration bits, ID locations and/or EEPROM data. See the Settings dialog for read options. Blank Check All Check to see that all device memory is erased/blank. Erase Flash Device Erase all Flash memory. Settings Open the Programmer dialog (see Section 9.5 Settings Dialog). Set up program and firmware options.
9.4.2
Toolbars/Status Bar
When the MPLAB ICD 3 in-circuit debugger is selected as a programmer, these toolbars are displayed in MPLAB IDE: Basic program toolbar (Blank Check All, Read, Program, Verify, Erase Flash Device). The selected programmer (MPLAB ICD 3), as well as other programming information, is displayed in the status bar on the bottom of the MPLAB IDE desktop. Refer to the MPLAB IDE online help for information on the contents of the status bar.
DS51766B-page 85
Settings Dialog, Program Memory Tab Settings Dialog, Configuration Tab Settings Dialog, Freeze on Halt Tab Settings Dialog, Status Tab Settings Dialog, Secure Segment Tab Settings Dialog, Warnings Tab Settings Dialog, Power Tab Settings Dialog, Limitations Tab Settings Dialog, Calibration Memory Tab
9.5.1
Program Options: Erase all before Program Check to erase all memory before programming begins. Unless programming new or already erased devices, it is important to have this box checked. If not checked, the device is not erased and program code will be merged with the code already in the device.
DS51766B-page 86
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 configuration setting, you must check the Use high voltage on MCLR option. 4. If you are using a -ICE header, the setting of this checkbox does not matter.
Automatically Program after successful After the application code successfully builds, program this code build 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.
9.5.2
DS51766B-page 87
9.5.3
9.5.4
View the status of your MPLAB ICD 3 system on this tab. TABLE 9-9:
Versions Firmware Suite Version FPGA Version
Algorithm Plug-in Version Debugger algorithm plug-in version. For your selected device, an algorithm is used to support the device plugged into the target. OS Version Voltages ICD 3 VPP ICD 3 VDD Target VDD Refresh Voltages Debugger VPP. Debugger VDD. VDD sensed at target. Sensing of Status tab items occurs when the tab is achieved. To see updates otherwise, click this button. Debugger operating system version.
DS51766B-page 88
9.5.6
A list of all MPLAB ICD 3 in-circuit debugger warnings are displayed on this tab. Check a warning to enable it. The warning will be displayed in the Output window. Uncheck a warning to disable it. Warnings are not errors and will not stop your project from building. If you receive error messages, please see Chapter 7. Error Messages.
9.5.7
Set up the power options on this tab. Click in the checkbox to enable/disable Power target circuit from MPLAB ICD 3. If you enable (check) this option, the Power on/off button will be enabled on the toolbar. It will initially be in the Power-On state. Every time it is clicked it will toggle to the opposite state. If it is on, it will toggle to off, and if it is off it will toggle to on. If the Power target circuit setting is disabled (unchecked) the Power-on/off button will go back to the disabled state. Whatever state it is in when the project was last saved will be the state that it is in when the project is reopened. Adjust the slide bar to select the voltage. The value in the field changes according to your adjustments.
9.5.8
View device limitations highlights on this tab. Click Details to see all the limitations for the device.
9.5.9
For devices that have calibration memory, view and change calibration memory values on this tab. Note: Microchip recommends that you do not change the factory calibration settings or your device may not work as expected. CALIBRATION MEMORY OPTIONS
If you have received an error (82 or 83), this is the last value read that was valid before the error. Last calibration value read from memory. Check to program calibration memory with the value specified in New. Values are hexadecimal.
TABLE 9-11:
Last Valid Value Last Value
DS51766B-page 89
DS51766B-page 90
A.2
HIGHLIGHTS
This chapter discusses: Declaration of Conformity USB Port/Power MPLAB ICD 3 Debugger Standard Communication Hardware ICD 3 Test Interface Board Target Board Considerations
A.3
DECLARATION OF CONFORMITY
We Microchip Technology, Inc. 2355 W. Chandler Blvd. Chandler, Arizona 85224-6199 USA hereby declare that the product: MPLAB ICD 3 In-Circuit Debugger complies with the following standards, provided that the restrictions stated in the operating manual are observed: Standards: EN61010-1 Laboratory Equipment Microchip Technology, Inc. Date: August 2006 Important Information Concerning the Use of the MPLAB ICD 3 In-Circuit Debugger Due to the special nature of the MPLAB ICD 3 in-circuit debugger, the user is advised that it can generate higher than normal levels of electromagnetic radiation which can interfere with the operation of all kinds of radio and other equipment. To comply with the European Approval Regulations therefore, the following restrictions must be observed: 1. The development system must be used only in an industrial (or comparable) area. 2. The system must not be operated within 20 meters of any equipment which may be affected by such emissions (radio receivers, TVs etc.).
DS51766B-page 91
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.
A.5
A.5.1
Main Board
This component has the interface processor (dsPIC DSC), the USB 2.0 interface capable of USB speeds of 480 Mb/sec., a Field Programmable Gate Array (FPGA) for general system control and increased communication throughput, an SRAM for holding the program code image for programming into the emulation device on-board Flash and LED indicators.
A.5.2
LED Active Status
DS51766B-page 92
Hardware Specification
A.6 STANDARD COMMUNICATION HARDWARE
For standard debugger communication with a target (, Standard ICSP Device Communication), use the RJ-11 connector. To use this type of communication with a header board, you may need a device-specific Processor Pak, which includes an 8-pin connector header board containing the desired ICE/ICD device and a standard adapter board. 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.
See the Header Board Specification (DS51292) for more on available header boards.
A.6.1
Standard Communication
The standard communication is the main interface to the target processor. It contains the connections to the high voltage (VPP), VDD sense lines, and clock and data connections required for programming and connecting with the target devices. The VPP high-voltage lines can produce a variable voltage that can swing from 0 to 14 volts to satisfy the voltage requirements for the specific emulation processor. The VDD sense connection draws very little current from the target processor. The actual power comes from the MPLAB ICD 3 in-circuit debugger system as the VDD sense line is used as a reference only to track the target voltage. The VDD connection is isolated with an optical switch. The clock and data connections are interfaces with the following characteristics: Clock and data signals are in High-Impedance mode (even when no power is applied to the MPLAB ICD 3 in-circuit debugger system) Clock and data signals are protected from high voltages caused by faulty targets systems, or improper connections Clock and data signals are protected from high current caused from electrical shorts in faulty target systems FIGURE A-1: 6-PIN STANDARD PINOUT
Pin 1 2 3 4 5 6 Name VPP VDD_TGT GND PGD (ICSPDAT) PGC (ICSPCLK) PGM (LVP) Function Power Power on target Ground Standard Com Data Standard Com Clock Low-Voltage Programming
Standard Socket
2 1
4 6 3 5
Bottom of Target Board
DS51766B-page 93
Note:
A.6.2
For standard communications, a modular cable connects the debugger and the target application. The specifications for this cable and its connectors are listed below. A.6.2.1 MODULAR CONNECTOR SPECIFICATION
Manufacturer, Part Number AMP Incorporated, 555165-1 Distributor, Part Number Digi-Key, A9031ND The following table shows how the modular connector pins on an application correspond to the microcontroller pins. This configuration provides full ICD functionality. FIGURE A-2: MODULAR CONNECTOR PINOUT OF TARGET BOARD
1 6
Microcontroller Pin
PGM (LVP) RB6 RB7 Ground VDD Target VPP
A.6.2.2
Manufacturer, Part Number AMP Incorporated, 5-554710-3 Distributor, Part Number Digi-Key, A9117ND
DS51766B-page 94
Hardware Specification
A.6.2.3 MODULAR CABLE SPECIFICATION Manufacturer, Part Number Microchip Technology, 07-00024 8.00
Pin 1
Pin 6
A.7
Modular Cable
USB/Power From PC
3. Connect the debugger to the PC. 4. Select the MPLAB ICD 3 in-circuit debugger as either a debugger or programmer in MPLAB IDE. If you get a device ID mismatch, open the Settings dialog (Debugger>Settings or Programmer>Settings), go to the Power tab and be sure that Power target circuit from ICD3 is unchecked. 5. Select Debugger>Reconnect if selected as a debugger and ignore the message ICD3Err0045: You must connect to a target device to use MPLAB ICD 3." in the Output window. 6. Once again open the Settings dialog and on the Status tab click Run ICD3 Test Interface. A reminder to have the test board connected will pop up. Click OK.
DS51766B-page 95
Interface test completed successfully. Your MPLAB ICD 3 is functioning properly and ready to use.
If any test failed, please enter a ticket on http://support.microchip.com/, copying and pasting the content of the output window in the problem description.
A.8
DS51766B-page 96
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.
DS51766B-page 97
DS51766B-page 98
Glossary
Calibration Memory A Special Function Register or registers used to hold values for calibration of a PIC microcontroller on-board RC oscillator or other device peripherals. Central Processing Unit The part of a device that is responsible for fetching the correct instruction for execution, decoding that instruction, and then executing that instruction. When necessary, it works in conjunction with the arithmetic logic unit (ALU) to complete the execution of the instruction. It controls the program memory address bus, the data memory address bus, and accesses to the stack. Clean Under the MPLAB IDE Project menu, Clean removes all intermediary project files, such as object, hex and debug files, for the active project. These files are recreated from other files when a project is built. COFF Common Object File Format. An object file of this format contains machine code, debugging and other information. Command Line Interface A means of communication between a program and its user based solely on textual input and output. Compiler A program that translates a source file written in a high-level language into machine code. Conditional Assembly Assembly language code that is included or omitted based on the assembly-time value of a specified expression. Conditional Compilation The act of compiling a program fragment only if a certain constant expression, specified by a preprocessor directive, is true. Configuration Bits Special-purpose bits programmed to set PIC microcontroller modes of operation. A Configuration bit may or may not be preprogrammed. Control Directives Directives in assembly language code that cause code to be included or omitted based on the assembly-time value of a specified expression. CPU See Central Processing Unit. Cross Reference File A file that references a table of symbols and a list of files that references the symbol. If the symbol is defined, the first file listed is the location of the definition. The remaining files contain references to the symbol. Data Directives Data directives are those that control the assemblers allocation of program or data memory and provide a way to refer to data items symbolically; that is, by meaningful names.
DS51766B-page 99
DS51766B-page 100
Glossary
ELF Executable and Linking Format. An object file of this format contains machine code. Debugging and other information is specified in with DWARF. ELF/DWARF provide better debugging of optimized code than COFF. Emulation The process of executing software loaded into emulation memory as if it were firmware residing on a microcontroller device. Emulation Memory Program memory contained within the emulator. Emulator Hardware that performs emulation. Emulator System The MPLAB ICE 2000 and MPLAB ICE 4000 emulator systems include the pod, processor module, device adapter, target board, cables, and MPLAB IDE software. The MPLAB REAL ICE system consists of a pod, a driver (and potentially a receiver) card, target board, cables, and MPLAB IDE software. Endianness The ordering of bytes in a multi-byte object. Environment IDE The particular layout of the desktop for application development. MPLAB PM3 A folder containing files on how to program a device. This folder can be transferred to a SD/MMC card. Epilogue A portion of compiler-generated code that is responsible for deallocating stack space, restoring registers and performing any other machine-specific requirement specified in the runtime model. This code executes after any user code for a given function, immediately prior to the function return. EPROM Erasable Programmable Read Only Memory. A programmable read-only memory that can be erased usually by exposure to ultraviolet radiation. Error File A file containing error messages and diagnostics generated by a language tool. Errors Errors report problems that make it impossible to continue processing your program. When possible, errors identify the source file name and line number where the problem is apparent. Event A description of a bus cycle which may include address, data, pass count, external input, cycle type (fetch, R/W), and time stamp. Events are used to describe triggers, breakpoints and interrupts. Executable Code Software that is ready to be loaded for execution. Export Send data out of the MPLAB IDE in a standardized format.
DS51766B-page 101
DS51766B-page 102
Glossary
Frame Pointer A pointer that references the location on the stack that separates the stack-based arguments from the stack-based local variables. Provides a convenient base from which to access local variables and other values for the current function. Free-Standing An implementation that accepts any strictly conforming program that does not use complex types and in which the use of the features specified in the library clause (ANSI 89 standard clause 7) is confined to the contents of the standard headers <float.h>, <iso646.h>, <limits.h>, <stdarg.h>, <stdbool.h>, <stddef.h> and <stdint.h>. GPR General Purpose Register. The portion of device data memory (RAM) available for general use. Halt A stop of program execution. Executing Halt is the same as stopping at a breakpoint. Heap An area of memory used for dynamic memory allocation where blocks of memory are allocated and freed in an arbitrary order determined at runtime. Hex Code Executable instructions stored in a hexadecimal format code. Hex code is contained in a hex file. Hex File An ASCII file containing hexadecimal addresses and values (hex code) suitable for programming a device. Hexadecimal The base 16 numbering system that uses the digits 0-9 plus the letters A-F (or a-f). The digits A-F represent hexadecimal digits with values of (decimal) 10 to 15. The rightmost digit counts ones, the next counts multiples of 16, then 162 = 256, etc. High Level Language A language for writing programs that is further removed from the processor than assembly. ICD In-Circuit Debugger. MPLAB ICD and PICkit (with Debug Express), are Microchips in-circuit debuggers. ICE In-Circuit Emulator. MPLAB ICE 2000 and MPLAB ICE 4000 system are Microchips classic in-circuit emulators. MPLAB REAL ICE system is Microchips next-generation in-circuit emulator. ICSP In-Circuit Serial Programming. A method of programming Microchip embedded devices using serial communication and a minimum number of device pins. IDE Integrated Development Environment. MPLAB IDE is Microchips integrated development environment. Identifier A function or variable name.
DS51766B-page 103
DS51766B-page 104
Glossary
L-value An expression that refers to an object that can be examined and/or modified. An l-value expression is used on the left-hand side of an assignment. Latency The time between an event and its response. Librarian See Archiver. Library See Archive. Linker A language tool that combines object files and libraries to create executable code, resolving references from one module to another. Linker Script Files Linker script files are the command files of a linker. They define linker options and describe available memory on the target platform. Listing Directives Listing directives are those directives that control the assembler listing file format. They allow the specification of titles, pagination and other listing control. Listing File A listing file is an ASCII text file that shows the machine code generated for each C source statement, assembly instruction, assembler directive, or macro encountered in a source file. Little Endian A data ordering scheme for multi-byte data whereby the Least Significant Byte is stored at the lower addresses. Local Label A local label is one that is defined inside a macro with the LOCAL directive. These labels are particular to a given instance of a macros instantiation. In other words, the symbols and labels that are declared as local are no longer accessible after the ENDM macro is encountered. Logic Probes Up to 14 logic probes can be connected to some Microchip emulators. The logic probes provide external trace inputs, trigger output signal, +5V, and a common ground. Loop-Back Test Board Used to test the functionality of the MPLAB REAL ICE in-circuit emulator. LVDS Low Voltage Differential Signaling. A low noise, low-power, low amplitude method for high-speed (gigabits per second) data transmission over copper wire. LVDS differs from normal input/output (I/O) in a few ways: Normal digital I/O works with 5 volts as a high (binary 1) and 0 volts as a low (binary 0). When you use a differential, you add a third option (-5 volts), which provides an extra level with which to encode, and results in a higher maximum data transfer rate. A higher data transfer rate means fewer wires are required, as in UW (Ultra Wide) and UW-2/3 SCSI hard disks, which use only 68 wires. These devices require a high transfer rate over short distances. Using standard I/O transfer, SCSI hard drives would require a lot more than 68 wires.
DS51766B-page 105
DS51766B-page 106
Glossary
Microprocessor Mode One of the possible program memory configurations of PIC18 microcontrollers. In Microprocessor mode, the on-chip program memory is not used. The entire program memory is mapped externally. Mnemonics Text instructions that can be translated directly into machine code. Also referred to as opcodes. MPASM Assembler Microchip Technologys relocatable macro assembler for PIC microcontroller devices, KEELOQ devices and Microchip memory devices. MPLAB Language Tool for Device Microchips C compilers, assemblers and linkers for specified devices. Select the type of language tool based on the device you will be using for your application, e.g., if you will be creating C code on a PIC18 MCU, select the MPLAB C Compiler for PIC18 MCUs. MPLAB ICD Microchips in-circuit debuggers that works with MPLAB IDE. The ICDs supports Flash devices with built-in debug circuitry. The main component of each ICD is the pod. A complete system consists of a pod, header board (with a device-ICD), target board, cables, and MPLAB IDE software. MPLAB ICE 2000/4000 Not recommended for new designs. See the MPLAB REAL ICE in-circuit emulator. Microchips classic in-circuit emulators that work with MPLAB IDE. MPLAB ICE 2000 supports 8-bit PIC MCUs. MPLAB ICE 4000 supports PIC18F and PIC24 MCUs and dsPIC DSCs. The main component of each ICE is the pod. A complete system consists of a pod, processor module, cables, and MPLAB IDE software. MPLAB IDE Microchips Integrated Development Environment. MPLAB IDE comes with an editor, project manager and simulator. MPLAB PM3 A device programmer from Microchip. Programs PIC18 microcontrollers and dsPIC digital signal controllers. Can be used with MPLAB IDE or stand-alone. Replaces PRO MATE II. MPLAB REAL ICE In-Circuit Emulator Microchips next-generation in-circuit emulators that works with MPLAB IDE. The MPLAB REAL ICE emulator supports PIC MCUs and dsPIC DSCs. The main component of each ICE is the pod. A complete system consists of a pod, a driver (and potentially a receiver) card, cables, and MPLAB IDE software. MPLAB SIM Microchips simulator that works with MPLAB IDE in support of PIC MCU and dsPIC DSC devices. MPLIB Object Librarian Microchips librarian that can work with MPLAB IDE. MPLIB librarian is an object librarian for use with COFF object modules created using either MPASM assembler (mpasm or mpasmwin v2.0) or MPLAB C18 C compiler.
DS51766B-page 107
DS51766B-page 108
Glossary
One-to-One Project-Workspace Model The most common configuration for application development in MPLAB IDE to is have one project in one workspace. Select Configure>Settings, Projects tab and check Use one-to-one project-workspace model. Opcodes Operational Codes. See Mnemonics. Operators Symbols, like the plus sign + and the minus sign -, that are used when forming well-defined expressions. Each operator has an assigned precedence that is used to determine order of evaluation. OTP One Time Programmable. EPROM devices that are not in windowed packages. Since EPROM needs ultraviolet light to erase its memory, only windowed devices are erasable. Pass Counter A counter that decrements each time an event (such as the execution of an instruction at a particular address) occurs. When the pass count value reaches zero, the event is satisfied. You can assign the Pass Counter to break and trace logic, and to any sequential event in the complex trigger dialog. PC Personal Computer or Program Counter. PC Host Any PC running a supported Windows operating system. Persistent Data Data that is never cleared or initialized. Its intended use is so that an application can preserve data across a device reset. Phantom Byte An unimplemented byte in the dsPIC architecture that is used when treating the 24-bit instruction word as if it were a 32-bit instruction word. Phantom bytes appear in dsPIC hex files. PIC MCUs PIC microcontrollers (MCUs) refers to all Microchip microcontroller families. PICkit 1, 2, and 3 Microchips developmental device programmers with debug capability through Debug Express. See the Readme files for each tool to see which devices are supported. PICSTART Plus A developmental device programmer from Microchip. Programs 8-, 14-, 28-, and 40-pin PIC microcontrollers. Must be used with MPLAB IDE software. Plug-ins The MPLAB IDE has both built-in components and plug-in modules to configure the system for a variety of software and hardware tools. Several plug-in tools may be found under the Tools menu.
DS51766B-page 109
DS51766B-page 110
Glossary
Program Memory IDE The memory area in a device where instructions are stored. Also, the memory in the emulator or simulator containing the downloaded target application firmware. ALU30, C30 The memory area in a device where instructions are stored. Project A project contains the files needed to build an application (source code, linker script files, etc.) along with their associations to various build tools and build options. Prologue A portion of compiler-generated code that is responsible for allocating stack space, preserving registers and performing any other machine-specific requirement specified in the runtime model. This code executes before any user code for a given function. Prototype System A term referring to a user's target application, or target board. PWM Signals Pulse Width Modulation Signals. Certain PIC MCU devices have a PWM peripheral. Qualifier An address or an address range used by the Pass Counter or as an event before another operation in a complex trigger. Radix The number base, hex, or decimal, used in specifying an address. RAM Random Access Memory (Data Memory). Memory in which information can be accessed in any order. Raw Data The binary representation of code or data associated with a section. Read Only Memory Memory hardware that allows fast access to permanently stored data but prevents addition to or modification of the data. Real Time When an in-circuit emulator or debugger is released from the Halt state, the processor runs in Real Time mode and behaves exactly as the normal chip would behave. In Real-Time mode, the real-time trace buffer of an emulator is enabled and constantly captures all selected cycles, and all break logic is enabled. In an in-circuit emulator or debugger, the processor executes in real time until a valid breakpoint causes a Halt, or until the user halts the execution. In the simulator, real time simply means execution of the microcontroller instructions as fast as they can be simulated by the host CPU. Real-Time Watch A Watch window where the variables change in real-time as the application is run. See individual tool documentation to determine how to set up a real-time watch. Not all tools support real-time watches. Recursive Calls A function that calls itself, either directly or indirectly.
DS51766B-page 111
DS51766B-page 112
Glossary
Shell The MPASM assembler shell is a prompted input interface to the macro assembler. There are two MPASM assembler shells: one for the DOS version and one for the Windows version. Simulator A software program that models the operation of devices. Single Step This command steps through code, one instruction at a time. After each instruction, MPLAB IDE updates register windows, watch variables, and status displays so you can analyze and debug instruction execution. You can also single step C compiler source code, but instead of executing single instructions, MPLAB IDE will execute all assembly level instructions generated by the line of the high level C statement. Skew The information associated with the execution of an instruction appears on the processor bus at different times. For example, the executed opcodes appears on the bus as a fetch during the execution of the previous instruction, the source data address and value and the destination data address appear when the opcodes is actually executed, and the destination data value appears when the next instruction is executed. The trace buffer captures the information that is on the bus at one instance. Therefore, one trace buffer entry will contain execution information for three instructions. The number of captured cycles from one piece of information to another for a single instruction execution is referred to as the skew. Skid When a hardware breakpoint is used to halt the processor, one or more additional instructions may be executed before the processor halts. The number of extra instructions executed after the intended breakpoint is referred to as the skid. Source Code The form in which a computer program is written by the programmer. Source code is written in a formal programming language which can be translated into machine code or executed by an interpreter. Source File An ASCII text file containing source code. Special Function Registers The portion of data memory (RAM) dedicated to registers that control I/O processor functions, I/O status, timers or other modes or peripherals. SQTP See Serialized Quick Turn Programming. Stack, Hardware Locations in the PIC microcontroller where the return address is stored when a function call is made. Stack, Software Memory used by an application for storing return addresses, function parameters, and local variables. This memory is typically managed by the compiler when developing code in a high-level language. MPLAB Starter Kit for Device Microchips starter kits contains everything needed to begin exploring the specified device. View a working application and then debug and program you own changes.
DS51766B-page 113
DS51766B-page 114
Glossary
Target Application Software residing on the target board. Target Board The circuitry and programmable device that makes up the target application. Target Processor The microcontroller device on the target application board. Template Lines of text that you build for inserting into your files at a later time. The MPLAB Editor stores templates in template files. Tool Bar A row or column of icons that you can click on to execute MPLAB IDE functions. Trace An emulator or simulator function that logs program execution. The emulator logs program execution into its trace buffer which is uploaded to MPLAB IDEs trace window. Trace Memory Trace memory contained within the emulator. Trace memory is sometimes called the trace buffer. Trace Macro A macro that will provide trace information from emulator data. Since this is a software trace, the macro must be added to code, the code must be recompiled or reassembled, and the target device must be programmed with this code before trace will work. Trigger Output Trigger output refers to an emulator output signal that can be generated at any address or address range, and is independent of the trace and breakpoint settings. Any number of trigger output points can be set. Trigraphs Three-character sequences, all starting with ??, that are defined by ISO C as replacements for single characters. Unassigned Section A section which has not been assigned to a specific target memory block in the linker command file. The linker must find a target memory block in which to allocate an unassigned section. Uninitialized Data Data which is defined without an initial value. In C, int myVar; defines a variable which will reside in an uninitialized data section. Upload The Upload function transfers data from a tool, such as an emulator or programmer, to the host PC or from the target board to the emulator. USB Universal Serial Bus. An external peripheral interface standard for communication between a computer and external peripherals over a cable using bi-serial transmission. USB 1.0/1.1 supports data transfer rates of 12 Mbps. Also referred to as high-speed USB, USB 2.0 supports data rates up to 480 Mbps.
DS51766B-page 115
DS51766B-page 116
E
Erase........................................................................ 85 Erase All Before Programming................................. 41 Erase Flash Device .................................................. 76 Explorer 16 Demo Board.......................................... 33
B
Blank Check ............................................................. 85 Breakpoints Dialog................................................................ 78 Enabling............................................................ 77 Hardware ...............................................45, 73, 87 Setup .....................................................45, 73, 76 Software.................................................54, 73, 87 Build Configuration..............................................24, 69
F
Firmware Cancelled Download ......................................... 62 Disconnected while Downloading ..................... 62 Firmware Downloads ............................................... 87 Freeze on Halt.......................................................... 60
G
General Corrective Actions ...................................... 67
H
Halt........................................................................... 75 Hardware Breakpoints.............................................. 45 Header Board Specification...................................................... 10 Hex File .................................................................... 41 Hibernate mode.............................................60, 61, 92 Hubs, USB ............................................................... 92
C
Cables Length ..........................................................92, 95 Capacitors ...........................................................20, 21 CD-ROM .................................................................. 16 Circuits That Will Prevent the Debugger From Functioning ................................................. 21 Code Protect ............................................................ 22 CodeGuard Security ................................................ 89 Command-line Programming ................................... 24 Configuration Bits..........................................22, 30, 40 Creating a Hex File .................................................. 41 Customer Notification Service.................................. 11 Customer Support .................................................... 12
I
ICD 3 Test Interface Board ...................................... 16 ICD Headers ............................................................ 16 ICD3CMD................................................................. 24 ICD3Err0001 ............................................................ 63 ICD3Err0002 ............................................................ 63 ICD3Err0003 ............................................................ 63 ICD3Err0005 ............................................................ 63 ICD3Err0006 ............................................................ 63 ICD3Err0007 ............................................................ 63 ICD3Err0008 ............................................................ 63 ICD3Err0009 ............................................................ 63 ICD3Err0010 ............................................................ 63 ICD3Err0011 ............................................................ 63 ICD3Err0012 ............................................................ 64 ICD3Err0013 ............................................................ 64 ICD3Err0014 ............................................................ 64 ICD3Err0015 ............................................................ 64 ICD3Err0016 ............................................................ 64 ICD3Err0017 ............................................................ 64 ICD3Err0018 ............................................................ 64 ICD3Err0019 ............................................................ 64 ICD3Err0020 ............................................................ 64 ICD3Err0021 ............................................................ 64 ICD3Err0022 ............................................................ 64 ICD3Err0023 ............................................................ 64 ICD3Err0024 ............................................................ 64
D
Debug Executive .......................................................... 23 Registers........................................................... 24 Debug Mode Sequence of Operations ................................... 22 Debug Read............................................................. 76 Debug/Program Quick Reference ............................ 31 Debugger Menu ....................................................... 44 Debugging................................................................ 44 Demo Board............................................................. 43 Device Debug Resource Toolbar ............................. 73 Documentation Conventions ........................................................ 9 Layout ................................................................. 7 Download Firmware ................................................. 87 Driver Board Standard ........................................................... 93 Durability, Card Guide.............................................. 92
DS51766B-page 117
P
PC, Power Down .......................................... 60, 61, 92 PGC................................................... 19, 20, 21, 22, 23 PGD................................................... 19, 20, 21, 22, 23 PIC24FJ128GA010, Tutorial .................................... 33 PIM ........................................................................... 18 Port A ....................................................................... 33 Power-Down mode....................................... 60, 61, 92 Processor Extension Kits ......................................... 16 Program.............................................................. 76, 85 Program Memory Tab .............................................. 41 Programming............................................................ 55 Command-line................................................... 24 Production ................................................... 15, 24 Programming Options .............................................. 41 Project Wizard .................................................... 30, 37 Pull-ups .................................................................... 21
Q
Quick Reference Debug/Program ................................................. 31
R
Read................................................................... 76, 85 Reading, Recommended.......................................... 10 Readme.................................................................... 10 Reconnect ................................................................ 76 Reserved Resources by Device ............................... 24 Reset Processor .......................................................... 76 Resistors .................................................................. 21 Run........................................................................... 75 Running code ........................................................... 44
S
Secure Segments..................................................... 89 Selecting Device and Development Mode ............... 34 Set a Breakpoint....................................................... 45 Setting Program and Debug Options ....................... 42 Setting Up Hardware and Software.......................... 34 Software Breakpoints ............................................... 54 SQTP........................................................................ 31 Standard Communication Connections ...................................................... 19 Driver Board ...................................................... 93 Standard ICSP Device Communication ................... 18 Step .......................................................................... 75 Stopwatch........................................................... 53, 73
K
Kit Components........................................................ 16
L
LEDs .................................................................. 33, 92 Light Icons ................................................................ 34 Loading Program and Debug Code.......................... 43
T
Table Read Protect .................................................. 22 Target Connection Circuitry ............................................................. 19 Improper Circuits............................................... 21 Standard............................................................ 19 Target Device ........................................................... 22 Timer1 ...................................................................... 33 Toolbar Buttons ........................................................ 44 Transition Socket...................................................... 16 Specification................................................ 10, 27
M
Microchip Internet Web Site ..................................... 11 Modular Interface Cable ........................................... 22 MPLAB C30 ............................................................. 37 MPLAB ICD 3 Defined.............................................. 15 MPLAB ICD 3 Test Interface Board ......................... 95
DS51766B-page 118
Index
Tutorial ..................................................................... 33
U
USB...................................................................92, 115 Cables............................................................... 16 Device Drivers .................................................. 25 Hubs ................................................................. 92
V
Vcap ......................................................................... 20 Vdd.......................................................... 19, 20, 21, 22 Verify ........................................................................ 85 Vpp.................................................... 19, 20, 21, 22, 23 Vss .......................................................... 19, 20, 21, 22
W
Warranty Registration .............................................. 10 Watch Window ......................................................... 46 Watchdog Timer................................................22, 116 WWW Address......................................................... 11
DS51766B-page 119
ASIA/PACIFIC
Asia Pacific Office Suites 3707-14, 37th Floor Tower 6, The Gateway Harbour City, Kowloon Hong Kong Tel: 852-2401-1200 Fax: 852-2401-3431 Australia - Sydney Tel: 61-2-9868-6733 Fax: 61-2-9868-6755 China - Beijing Tel: 86-10-8528-2100 Fax: 86-10-8528-2104 China - Chengdu Tel: 86-28-8665-5511 Fax: 86-28-8665-7889 China - Chongqing Tel: 86-23-8980-9588 Fax: 86-23-8980-9500 China - Hong Kong SAR Tel: 852-2401-1200 Fax: 852-2401-3431 China - Nanjing Tel: 86-25-8473-2460 Fax: 86-25-8473-2470 China - Qingdao Tel: 86-532-8502-7355 Fax: 86-532-8502-7205 China - Shanghai Tel: 86-21-5407-5533 Fax: 86-21-5407-5066 China - Shenyang Tel: 86-24-2334-2829 Fax: 86-24-2334-2393 China - Shenzhen Tel: 86-755-8203-2660 Fax: 86-755-8203-1760 China - Wuhan Tel: 86-27-5980-5300 Fax: 86-27-5980-5118 China - Xian Tel: 86-29-8833-7252 Fax: 86-29-8833-7256 China - Xiamen Tel: 86-592-2388138 Fax: 86-592-2388130 China - Zhuhai Tel: 86-756-3210040 Fax: 86-756-3210049
ASIA/PACIFIC
India - Bangalore Tel: 91-80-3090-4444 Fax: 91-80-3090-4123 India - New Delhi Tel: 91-11-4160-8631 Fax: 91-11-4160-8632 India - Pune Tel: 91-20-2566-1512 Fax: 91-20-2566-1513 Japan - Yokohama Tel: 81-45-471- 6166 Fax: 81-45-471-6122 Korea - Daegu Tel: 82-53-744-4301 Fax: 82-53-744-4302 Korea - Seoul Tel: 82-2-554-7200 Fax: 82-2-558-5932 or 82-2-558-5934 Malaysia - Kuala Lumpur Tel: 60-3-6201-9857 Fax: 60-3-6201-9859 Malaysia - Penang Tel: 60-4-227-8870 Fax: 60-4-227-4068 Philippines - Manila Tel: 63-2-634-9065 Fax: 63-2-634-9069 Singapore Tel: 65-6334-8870 Fax: 65-6334-8850 Taiwan - Hsin Chu Tel: 886-3-6578-300 Fax: 886-3-6578-370 Taiwan - Kaohsiung Tel: 886-7-213-7830 Fax: 886-7-330-9305 Taiwan - Taipei Tel: 886-2-2500-6610 Fax: 886-2-2508-0102 Thailand - Bangkok Tel: 66-2-694-1351 Fax: 66-2-694-1350
EUROPE
Austria - Wels Tel: 43-7242-2244-39 Fax: 43-7242-2244-393 Denmark - Copenhagen Tel: 45-4450-2828 Fax: 45-4485-2829 France - Paris Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79 Germany - Munich Tel: 49-89-627-144-0 Fax: 49-89-627-144-44 Italy - Milan Tel: 39-0331-742611 Fax: 39-0331-466781 Netherlands - Drunen Tel: 31-416-690399 Fax: 31-416-690340 Spain - Madrid Tel: 34-91-708-08-90 Fax: 34-91-708-08-91 UK - Wokingham Tel: 44-118-921-5869 Fax: 44-118-921-5820
07/15/10
DS51766B-page 120