Page 2
MPLAB and The Embedded Control Solutions Company are reg- No representation or warranty is given and no liability is istered trademarks of Microchip Technology Incorporated in the assumed by Microchip Technology Incorporated with respect U.S.A. and other countries.
Highlights ..................27 What MPLAB ICE Is ..............27 MPLAB ICE System Components ..........28 How MPLAB ICE Helps You ............29 MPLAB ICE Kit Components ............30 Installing MPLAB ICE Hardware ........... 31 Applying Power to the System Components ........ 32 Installing MPLAB IDE Software ............
Page 4
Building the Project ...............70 Using Software Break Points ............70 Using Named Software Break Points ..........72 3.10 Using Hardware Break Points ............73 3.11 Using the Complex Trigger ............74 3.12 Using Code Coverage ..............77 3.13 Going Forward ................79 2001 Microchip Technology Inc. DS51159B-page iv...
Page 5
5.10 Using Trigger In/Out Settings ............96 Chapter 6. Advanced Features Introduction ................... 97 Highlights ..................97 Using Complex Triggering ............98 Using Code Coverage ..............118 Using the Trace Memory Window ..........120 2001 Microchip Technology Inc. DS51159B-page v...
Page 6
Running Verify ................127 Troubleshooting Verify Failures ..........132 Chapter 8. Troubleshooting Introduction .................133 Highlights ..................133 Common Problems ..............133 Configuring a PC’s Parallel Interface for MPLAB ICE ....135 Appendix A. Debugging Techniques Introduction .................141 Highlights ..................141 Complex Triggering Examples ............141 Additional Debugging Examples ..........142 Appendix B.
Page 7
Table of Contents Glossary Introduction .................... 169 Highlights ....................169 Terms ....................169 Index ......................... 185 Worldwide Sales and Service ................192 2001 Microchip Technology Inc. DS51159B-page vii...
ICE USER’S GUIDE Quick Start Introduction This chapter is designed to get you up and running using the MPLAB ICE emulator as quickly as possible. It is assumed that you have a working ® knowledge of computer hardware terms, of the Windows operating system, of MPLAB IDE software and of general emulator operation.
Connect one end of the parallel cable to the parallel connector on the MPLAB ICE pod and connect the other end to the LPT port on the PC chassis. Secure both ends with the cable screws. 2001 Microchip Technology Inc.
Page 11
• Attach the power supply. Make certain that the MPLAB ICE pod on/off switch is in the “O” or “off” position before completing this step. Plug the appropriate ends of the power supply into a power outlet and into the back of the MPLAB ICE pod.
User’s Guide (DS51025) and the included file README.LAB. Setting Up the Development Mode Open the Development Mode dialog to set up the MPLAB ICE emulator for use with MPLAB IDE software. Select Options>Development Mode. Set up the development mode by clicking on each tab of the dialog and setting options as specified below.
Page 13
MPLAB User’s Guide (DS51025). If you have difficulty setting up the development mode, please refer to the more detailed chapter on set up (Chapter 4) or consult the troubleshooting chapter (Chapter 8). 2001 Microchip Technology Inc. DS51159B-page 13...
ICE User’s Guide Using MPLAB ICE MPLAB ICE provides a wide variety of tools to emulate and debug an application. MPLAB ICE offers a basic set of in-circuit debugging tools, including the ability to run, halt, reset and single step the processor, plus additional tools for advanced debugging techniques.
Page 15
Trace; otherwise, the trace buffer will capture the cycle that executes after the cycle that caused the trigger. Note: Since Ignore FNOP Cycles should not be specified with a Filter Trace, prefetches will cause the trigger to fire. 2001 Microchip Technology Inc. DS51159B-page 15...
Page 16
Using the Trace Memory Window The trace memory window in MPLAB ICE contains information that is uploaded from MPLAB ICE’s trace buffer. By default, all instruction cycles are captured by the trace buffer. The Complex Trigger dialog can be used to control which instruction cycles are captured (see Using Complex Triggering).
Page 17
Select Options>Configure to further customize the trace display. Usage Problems If you have difficulty using any of the features of MPLAB ICE, please refer to the more detailed chapters on features (Chapter 5 or Chapter 6) or consult the troubleshooting chapter (Chapter 8).
The manual layout is as follows: • Quick Start – How to get up and running quickly using MPLAB ICE. • Chapter 1: Overview and Installation – What MPLAB ICE is and how it can help you.
Page 20
® MPLAB ICE User’s Guide • Chapter 7: Verification – How to verify MPLAB ICE’s correct opera- tion. • Chapter 8: Troubleshooting – How to solve common problems with MPLAB ICE operation. • Appendix A: Debugging Techniques – How to debug common prob- lems in your code by using MPLAB ICE.
Please complete the enclosed Warranty Registration Card and mail it promptly. Sending in your Warranty Registration Card entitles you to receive new product updates. Interim software releases are available at the Microchip web site. 2001 Microchip Technology Inc. DS51159B-page 21...
For the latest information on using MPLAB ICE, read the README.ICE file (an ASCII text file) on the MPLAB IDE CD-ROM. README.ICE contains update information that may not be included in the MPLAB ICE User’s Guide. README.XXX For the latest information on using other tools, refer to an information file about the product that is more current than the printed manual.
• Job Postings • Microchip Consultant Program Member Listing • Links to other useful web sites related to Microchip Products • Conferences for products, development systems, technical information • Listing of seminars and events 2001 Microchip Technology Inc. DS51159B-page 23...
These include MPLAB C17, MPLAB C18, MPLINK and MPASM , as well ™ as the Librarian, MPLIB for MPLINK. To SUBSCRIBE to this list, send a message to: listserv@mail.microchip.com with the following as the body: subscribe compilers yourname 2001 Microchip Technology Inc. DS51159B-page 24...
Page 25
General Information Emulators The latest information on Microchip In-Circuit Emulators. These include ® MPLAB ICE and PICMASTER emulator. To SUBSCRIBE to this list, send a message to: listserv@mail.microchip.com with the following as the body: subscribe emulators yourname Programmers The latest information on Microchip PICmicro microcontroller (MCU) device ®...
Plus, this line provides information on how customers can receive any currently available upgrade kits. The Hotline Numbers are: 1-800-755-2345 for U.S. and most of Canada. 1-480-792-7302 for the rest of the world. 2001 Microchip Technology Inc. DS51159B-page 26...
MPLAB ICE USER’S GUIDE Chapter 1. Overview and Installation Introduction This chapter gives you an overview of the MPLAB ICE system and then explains how to install the system hardware and software. Highlights This chapter discusses: • What MPLAB ICE Is •...
® MPLAB ICE User’s Guide MPLAB ICE System Components The MPLAB ICE system consists of these items (Figure 1.1): 1. Emulator pod 2. Parallel cable to connect the emulator pod to a PC 3. Power supply cable 4. Processor module with cable 5.
Overview and Installation How MPLAB ICE Helps You MPLAB ICE allows you to: • Debug your application on your own hardware in real time. • Debug with both hardware and software break points. • Measure timing between events. • Set break points based on internal and/or external signals.
® MPLAB ICE User’s Guide MPLAB ICE Kit Components The components of the MPLAB ICE emulator kit, plus additional hardware, are shown in Figure 1.2. 1. User’s Guide 2. CD-ROM with MPLAB IDE software and on-line documentation 3. Parallel cable to connect the emulator pod to a PC 4.
Connect one end of the parallel cable to the parallel connector on the MPLAB ICE pod and connect the other end to the LPT port on the PC chassis. Secure both ends with the cable screws. • Install the processor module.
4. Apply power to the target application circuit. MPLAB ICE allows the emulator processor chip to be powered by either the emulator pod or the target system. This is set up in MPLAB as follows: •...
Page 33
1.8.2 Turning On the System Components – Low Voltage Emulation MPLAB ICE also supports low voltage emulation, from 2.0V to 4.5V. In this configuration, power MUST BE SUPPLIED by the target system. Note: When power is supplied by the emulator pod, MPLAB ICE loads the system at 10 mA typical.
Page 34
4. Set up MPLAB. From MPLAB, select Options>Development Mode. Click the Ports tab and set up the MPLAB ICE LPT port. Click the Tools tab and set up the devel- opment mode for MPLAB ICE Emulator and for your desired processor.
Installing MPLAB IDE Software To install the MPLAB IDE software, refer to the installation instructions found in the MPLAB User’s Guide (DS51025). The MPLAB ICE emulator functions with MPLAB IDE software under the following operating systems: • Microsoft Windows 3.1x •...
® MPLAB ICE USER’S GUIDE Chapter 2. Tutorial - PIC16CXXX Introduction After installing the MPLAB ICE hardware and MPLAB software, you may wish to try this tutorial to get you started. Highlights This tutorial covers: • Reviewing the Hardware • Running MPLAB •...
After installing MPLAB IDE software, invoke it by executing the file MPLAB.EXE. For more information on using MPLAB, refer to the MPLAB User’s Guide (DS51025) and the included file README.LAB. Figure 2.1: MPLAB IDE 2001 Microchip Technology Inc. DS51159B-page 38...
Setting Up the Development Mode Open the Development Mode dialog (Options>Development Mode) to set up the MPLAB ICE emulator for use with MPLAB IDE software. Set up the development mode by clicking on each tab of the dialog and setting options as specified below.
Page 40
Choose the PIC16C74B processor to emulate from the dropdown list. Below the processor is a brief description of any limitations that exist for emulating this processor on the MPLAB ICE emulator. A more detailed description of limitations may be viewed by clicking on Details.
Page 41
Global Break Enable and Freeze Peripherals On Halt. For this tutorial, uncheck Freeze Peripherals On Halt. Figure 2.4: Development Mode Dialog – Break Options Tab Click Apply to accept the setting of this tab. 2001 Microchip Technology Inc. DS51159B-page 41...
Also, you should copy the file icetut16.asm from the MPLAB install directory to this project directory to keep all project files in one place. 2001 Microchip Technology Inc. DS51159B-page 42...
Page 43
Find the directory you created for the project and then name the project icetut16.pjt. Click OK to close this dialog and open the Edit Project dialog. Figure 2.6: Edit Project Dialog – Hex File Only 2001 Microchip Technology Inc. DS51159B-page 43...
Page 44
If you could not file this file, or if it was missing, type icetut16.asm in the File name box of the dialog. Click OK to close this dialog and return to the Edit Project dialog. 2001 Microchip Technology Inc. DS51159B-page 44...
Page 45
Proceed to the next section. If you could not find the file icetut16.asm to copy to the project directory, you should now be in the main MPLAB IDE window with one empty open file window called Untitled. 2001 Microchip Technology Inc. DS51159B-page 45...
Page 46
TEMP3 0x22 0x00 ;Reset Vector goto START 0x05 ;Start Program START clrf PORTB ;Clear PortB (LED’s off) STATUS, RP0 ;Select Bank 1 clrf TRISB ;Set PortB as output STATUS, RP0 ;Select Bank 0 2001 Microchip Technology Inc. DS51159B-page 46...
Page 47
TEMP2, F goto DLOOP decfsz TEMP3, F goto DLOOP return Save this file by using File>Save. Then close the file using File>Close or clicking on the right top corner of the window. 2001 Microchip Technology Inc. DS51159B-page 47...
Now that your project has been built and the source code successfully assembled into an executable (.hex) program, you may run this program on MPLAB ICE using MPLAB IDE. Open the source code file in a window by first selecting File>Open to open the Open Existing File dialog.
Page 49
The status bar on the bottom of the MPLAB IDE window will change color, indicating that the program is running. The program will halt when it reaches the break point. 2001 Microchip Technology Inc. DS51159B-page 49...
Watch_1 watch window has changed from H’00’ to H’FF’ and should be a different color. This demonstrates how software break points work with MPLAB ICE. The break point halts an emulation run before the line of code it is associated with is executed.
Break Point(s). The line of code will change color. If you don’t like this color, you may change it by selecting Options>Environment Setup, clicking the Color tab, and selecting a different Color for Trigger Point Text. 2001 Microchip Technology Inc. DS51159B-page 51...
Right mouse button menu complex trigger break points are not. In this tutorial, the complex trigger will first be used as a hardware break point, and then as a trace memory capture. 2001 Microchip Technology Inc. DS51159B-page 52...
Page 53
Again, you should see the instruction movlw 0xFF of the DELAY routine highlighted, indicating that this is the instruction where program execution halted, (i.e., there was a 2 instruction skid). 2001 Microchip Technology Inc. DS51159B-page 53...
Page 54
• All Events • Any Event In addition, the complex triggering feature along with the trace memory window can be used to perform the following functions: • Time Between Events • Filter Trace 2001 Microchip Technology Inc. DS51159B-page 54...
Close, using the keys Ctrl+F4, or by selecting File>Close. Open the Program Memory window by selecting Window>Program Memory. Set a software break point at location 0x000A. Figure 2.19: Program Memory Window 2001 Microchip Technology Inc. DS51159B-page 55...
Page 56
All the code executed before the break point, and the line where the break point was set, will be "covered" (colored as Trace Point Text). For more information on code coverage, see Section 6.4. Figure 2.21: Program Memory Window - Code Coverage 2001 Microchip Technology Inc. DS51159B-page 56...
Tutorial - PIC16CXXX 2.13 Going Forward You have now completed the PIC16CXXX tutorial on MPLAB ICE and MPLAB IDE functionality. The simple examples shown here should give you a beginner’s knowledge of working with the emulator and software. For more detailed information on usage for your individual applications, please refer to the Basic (Chapter 5) and Advanced (Chapter 6) Features chapters.
® MPLAB ICE USER’S GUIDE Chapter 3. Tutorial - PIC18CXXX Introduction After installing the MPLAB ICE hardware and MPLAB software, you may wish to try this tutorial to get you started. Highlights This tutorial covers: • Reviewing the Hardware • Running MPLAB •...
After installing MPLAB IDE software, invoke it by executing the file MPLAB.EXE. For more information on using MPLAB, refer to the MPLAB User’s Guide (DS51025) and the included file README.LAB. Figure 3.1: MPLAB IDE 2001 Microchip Technology Inc. DS51159B-page 60...
Setting Up the Development Mode Open the Development Mode dialog (Options>Development Mode) to set up the MPLAB ICE emulator for use with MPLAB IDE software. Set up the development mode by clicking on each tab of the dialog and setting options as specified below.
Page 62
Choose the PIC18C252 processor to emulate from the dropdown list. Below the processor is a brief description of any limitations that exist for emulating this processor on the MPLAB ICE emulator. A more detailed description of limitations may be viewed by clicking on Details.
Page 63
Global Break Enable and Freeze Peripherals On Halt. For this tutorial, uncheck Freeze Peripherals On Halt. Figure 3.4: Development Mode Dialog – Break Options Tab Click Apply to accept the setting of this tab. 2001 Microchip Technology Inc. DS51159B-page 63...
Also, you should copy the file icetut18.asm from the MPLAB install directory to this project directory to keep all project files in one place. 2001 Microchip Technology Inc. DS51159B-page 64...
Page 65
Find the directory you created for the project and then name the project icetut18.pjt. Click OK to close this dialog and open the Edit Project dialog. Figure 3.6: Edit Project Dialog – Hex File Only 2001 Microchip Technology Inc. DS51159B-page 65...
Page 66
If you could not file this file, or if it was missing, type icetut18.asm in the File name box of the dialog. Click OK to close this dialog and return to the Edit Project dialog. 2001 Microchip Technology Inc. DS51159B-page 66...
Page 67
Proceed to the next section. If you could not find the file icetut18.asm to copy to the project directory, you should now be in the main MPLAB IDE window with one empty open file window called Untitled. 2001 Microchip Technology Inc. DS51159B-page 67...
Page 69
TEMP2, F goto DLOOP decfsz TEMP3, F goto DLOOP return Save this file by using File>Save. Then close the file using File>Close or clicking on the right top corner of the window. 2001 Microchip Technology Inc. DS51159B-page 69...
Now that your project has been built and the source code successfully assembled into an executable (.hex) program, you may run this program on MPLAB ICE using MPLAB IDE. Open the source code file in a window by first selecting File>Open to open the Open Existing File dialog.
Page 71
The status bar on the bottom of the MPLAB IDE window will change color, indicating that the program is running. The program will halt when it reaches the break point. 2001 Microchip Technology Inc. DS51159B-page 71...
Watch_1 watch window has changed from H’00’ to H’FF’ and should be a different color. This demonstrates how software break points work with MPLAB ICE. The break point halts an emulation run before the line of code it is associated with is executed.
Break Point(s). The line of code will change color. If you don’t like this color, you may change it by selecting Options>Environment Setup, clicking the Color tab, and selecting a different Color for Trigger Point Text. 2001 Microchip Technology Inc. DS51159B-page 73...
Right mouse button menu complex trigger break points are not. In this tutorial, the complex trigger will first be used as a hardware break point, and then as a trace memory capture. 2001 Microchip Technology Inc. DS51159B-page 74...
Page 75
Run the program by selecting Debug>Run>Run or by clicking the toolbar green stoplight icon. Again, you should see the instruction call DELAY highlighted, indicating that this is the instruction where program execution halted, (i.e., there was a 1 instruction skid). 2001 Microchip Technology Inc. DS51159B-page 75...
Page 76
In addition, the complex triggering feature along with the trace memory window can be used to perform the following functions: • Time Between Events • Filter Trace For more information on complex triggering, as well as complex triggering examples, see Section 6.3. 2001 Microchip Technology Inc. DS51159B-page 76...
Set a software break point at location 0x000A. Figure 3.19: Program Memory Window Enable code coverage by selecting Debug > Code Coverage. Click on Enabled/Reset on Run in the Code Coverage dialog, and then click OK. 2001 Microchip Technology Inc. DS51159B-page 77...
Page 78
All the code executed before the break point, and the line where the break point was set, will be "covered" (colored as Trace Point Text). Figure 3.21: Program Memory Window - Code Coverage For more information on code coverage, see Section 6.4. 2001 Microchip Technology Inc. DS51159B-page 78...
Tutorial - PIC18CXXX 3.13 Going Forward You have now completed the PIC18CXXX tutorial on MPLAB ICE and MPLAB IDE functionality. The simple examples shown here should give you a beginner’s knowledge of working with the emulator and software. For more detailed information on usage for your individual applications, please refer to the Basic (Chapter 5) and Advanced (Chapter 6) Features chapters.
ICE USER’S GUIDE Chapter 4. General Set Up Introduction After installing and starting up the MPLAB software, MPLAB ICE must be enabled and set up to correctly emulate the selected processor. Highlights The steps needed to get started with MPLAB ICE are: •...
That is, they can both send and receive 8-bit wide data. Most newer PC’s contain either a bi-directional port or a port that can be configured to either a bi-directional or compatibility mode port. 2001 Microchip Technology Inc. DS51159B-page 82...
General Set Up MPLAB ICE communicates in bi-directional mode if it is supported by the LPT port. However, if the host PC has difficulties communicating across the LPT port, try communicating in compatibility mode. To force compatibility mode communications, mark the Force Compatibility Mode checkbox. Also, verify the LPT port type by examining the BIOS for a parallel port that is on the PC’s...
Click Apply to accept the setting in this tab of the dialog. Selecting Processor Power MPLAB ICE allows the emulator processor chip to be powered by the emulator pod (5V) or the target system (2.0-5.5V). The emulator defaults to Processor Power from Emulator (system power) when first initialized.
Page 85
Figure 4.5: Development Mode Dialog – Power Tab, From Target Board 4.6.3 Low Voltage Emulation MPLAB ICE also supports LOW VOLTAGE emulation, from 2.0V to 4.6V. The emulator system cannot provide any voltage level other than 5V to the emulator processor. In this configuration, power must be supplied by the target board (see above).
4.7.2 Using a Target Board Clock MPLAB ICE can use the processor clock on the target board as long as target board (external) power is being used. It can determine the frequency (to within 3.5%) of the target board clock and use it for displaying timing information.
Target Board (see Section 4.6.2). Then select the Clock tab and select Use Target Board Clock. Note: If MPLAB ICE is not hooked up to a target board and you click Use Target Board Clock, you will get a warning dialog. Figure 4.7: Development Mode Dialog – Clock Tab, Target Clock The target board clock frequency will be calculated, displayed and used for any internal time calculations.
Page 88
These include Clear Break Points on Download, Global Break Enable, Disable Stack Overflow Warning and Freeze Peripherals on Halt. Additional options are Stack Overflow Break Enable and Stack Overflow Reset Enable. 2001 Microchip Technology Inc. DS51159B-page 88...
4.9.2 Saving the Project Once you have the MPLAB ICE system and software configured, it is advisable to save your current project to retain the values for later use, or use as a backup or default as you continue with your debugging.
Page 90
• Clock source and frequency • Source files associated with the project • Name of the final PICmicro executable file • Open windows and their sizes and positions • Named break settings • Configuration bit settings 2001 Microchip Technology Inc. DS51159B-page 90...
Chapter 5. Basic Features Introduction MPLAB ICE provides a wide variety of tools to emulate and debug an application. MPLAB ICE offers a basic set of in-circuit debugging tools, including the ability to run, halt, reset and single step the processor, plus additional tools for advanced debugging techniques.
MPLAB allows the contents of file registers to be monitored through a watch window. To open a watch window, select Window>New Watch Window. Modify To modify memory contents, use the Modify dialog accessed by selecting Window>Modify. 2001 Microchip Technology Inc. DS51159B-page 92...
Execute the instruction at the current program counter location and update all displayed emulation information. Note: Do not step into a SLEEP instruction. If you do, you will need to select Debug>System Reset in order to wake up the processor module. 2001 Microchip Technology Inc. DS51159B-page 93...
Execute one or more instructions without modifying the program memory. Using Software Break Points MPLAB ICE uses software break points to halt the processor at a specific location. With a software break point, execution stops before the instruction at the break location is executed.
Section 6.3. 5.10 Using Trigger In/Out Settings MPLAB ICE offers the following external input and output options: • Generate a single pulse of nonspecific duration, either on the final trig- ger event or on a filtered trace event. Use the positive edge to trigger other equipment.
Chapter 6. Advanced Features Introduction MPLAB ICE provides a wide variety of tools to emulate and debug an application. MPLAB ICE offers a basic set of in-circuit debugging tools, including the ability to run, halt, reset and single step the processor, plus additional tools for advanced debugging techniques.
® MPLAB ICE User’s Guide Using Complex Triggering MPLAB ICE has a highly flexible and powerful triggering mechanism. A trigger is a combination of events that can cause: • a hardware break point, and/or • a trace memory capture. An event is a description of the state of the system captured during one cycle.
Page 99
However, if the current instruction changes the program counter, this prefetched instruction is explicitly ignored, causing a forced NOP cycle. 2001 Microchip Technology Inc. DS51159B-page 99...
Page 100
• Save Event – Opens the Save Current Trigger Level dialog, allowing you to save as a *.trl file trigger information for the active tab of the dialog. • Clear Event – Clears the current trigger information in the active tab of the dialog. 2001 Microchip Technology Inc. DS51159B-page 100...
Page 101
• Apply – Accepts the current setting in the dialog without closing the dia- log. • Cancel – Closes the dialog without accepting the current settings. • Help – Brings up the on-line help file to walk you through setting up a complex trigger. 2001 Microchip Technology Inc. DS51159B-page 101...
Page 102
Data Memory Address — Address 21 All 14-Bit RETLW Program Memory 34xx Value instructions All 14-Bit RETLW Program Memory 3400:34FF Value Symbolic instructions Bit 4 high, bit 0 low Data Memory xxx1xxx0 Value Binary 2001 Microchip Technology Inc. DS51159B-page 102...
Page 103
Program Memory If a Program Memory access is specified, the trigger can be generated on an instruction fetch or a table read / table write operation. Figure 6.2: Complex Trigger - Program Memory Selection 2001 Microchip Technology Inc. DS51159B-page 103...
Page 104
• All Events • Any Event In addition, the complex triggering feature along with the trace memory window can be used to perform the following functions: • Time Between Events • Filter Trace 2001 Microchip Technology Inc. DS51159B-page 104...
Page 105
Event 2, Event 3 and the Trigger event have been satisfied. Therefore, always right-justify the trigger specification; that is, use the right-most event tabs first. 2001 Microchip Technology Inc. DS51159B-page 105...
Page 106
2. Click on a tab to enter information about each event (Event 1, Event 2, Event 3, Event 4). Figure 6.5: Complex Trigger - All Events Selection Pass Counter does not apply (grayed out) for this event selection as event timing is not necessary for triggering. 2001 Microchip Technology Inc. DS51159B-page 106...
Page 107
2. Click on a tab to enter information about each event (Event 1, Event 2, Event 3, Event 4). Figure 6.6: Complex Trigger - Any Event Selection Pass Counter does not apply (grayed out) for this event selection as event timing is not necessary for triggering. 2001 Microchip Technology Inc. DS51159B-page 107...
Page 108
The time between the events can be determined by examining the time stamp in the trace memory window. 2001 Microchip Technology Inc. DS51159B-page 108...
Page 109
First In, First Out (FIFO). This is useful in some special cases; 1. Capturing filtered events up until a user halt. You may wish to see the data collected up until the system was manually halted. 2001 Microchip Technology Inc. DS51159B-page 109...
Page 110
Note: When triggering on multiple events, keep in mind that triggers on data memory accesses are skewed two cycles from the instruc- tions that caused them. 2001 Microchip Technology Inc. DS51159B-page 110...
Page 111
RoutineA. The Ignore FNOP Cycles is left checked so prefetches are ignored, and Halt On Trigger is checked so the improperly executing subroutine can be stepped. Figure 6.9: Setting the First of Two Sequential Events 2001 Microchip Technology Inc. DS51159B-page 111...
Page 112
® MPLAB ICE User’s Guide Figure 6.10: Setting the Second of Two Sequential Events 2001 Microchip Technology Inc. DS51159B-page 112...
Page 113
Sequential trigger on a Write-to-Data Memory. Specify the Address as Flags and the Value as xxxx1xxx in binary. Uncheck Ignore FNOP Cycles and check Halt-On-Trigger if desired. Figure 6.11: Sequential Event - Triggering on Data Memory 2001 Microchip Technology Inc. DS51159B-page 113...
Page 114
After EndDelay is reached, the trace memory window will fill and the largest time stamp value will be the time between the two events. Figure 6.12: Specifying the Event that will Start the Timer 2001 Microchip Technology Inc. DS51159B-page 114...
Page 115
Advanced Features Figure 6.13: Specifying the Event that will Stop the Timer 2001 Microchip Technology Inc. DS51159B-page 115...
Page 116
Infinite Events and enter a value for Captured Events. When viewing the trace memory window, all instances of the delay code should be gone. Figure 6.14: Filter Trace 2001 Microchip Technology Inc. DS51159B-page 116...
Page 117
For instance, the register can be ANDed with a value of 0xFF to generate the extra cycle like this: test movlw 0xFF movwf LSDigit test1 decfsz LSDigit andwf LSDigit ; generate extra read/w to LSDigit goto test1 2001 Microchip Technology Inc. DS51159B-page 117...
Therefore, not all highlighted code may have been executed. Addresses transferred as a result of a table read (TBLRD) or table write (TBLWR) will be traced using this method. 2001 Microchip Technology Inc. DS51159B-page 118...
Page 119
To disable code coverage, select Debug>Code Coverage and click on Disabled. Note: Code coverage and complex triggering are mutually exclusive. While code coverage is enabled, complex triggering is disabled. When code coverage is disabled, previously defined triggers must be reapplied. 2001 Microchip Technology Inc. DS51159B-page 119...
The Complex Trigger dialog can be used to control which instruction cycles are captured (Section 6.3). In MPLAB ICE, the trace buffer captures data on a 128-bit wide analyzer that is connected to the emulator chip and other devices in the emulator (Figure 6.17).
Page 122
MPLAB ICE offers a trace memory window that monitors much of the processor operation. Up to 32767 instruction cycles can be displayed. The...
Page 123
Select Data>Reload to force an upload of what ever data has currently been collected by the trace buffer. This allows you to see where your program is executing. This is often useful if your trigger is never reached. 2001 Microchip Technology Inc. DS51159B-page 123...
Page 124
• Keeping the number of Uploaded Trace Lines to a minimum will also result in a faster display time. To display more of the information currently in the emulator’s trace memory, increase the number of Uploaded Trace Lines, click OK, then select Data/ Reload. 2001 Microchip Technology Inc. DS51159B-page 124...
Page 125
1. The first cycle, a Decrement File and Skip if Zero is applied to a variable at location 0x20 2. The next cycle, the value of this variable is decremented from 2 to 1 Figure 6.21: Trace Memory Window – Example 2 2001 Microchip Technology Inc. DS51159B-page 125...
® MPLAB ICE USER’S GUIDE Chapter 7. Verification Introduction This section describes how to verify that the MPLAB ICE system hardware is functional. Highlights This section discusses: • Running Verify • Troubleshooting Verify Failures Running Verify MPLAB ICE verification is a diagnostic tool designed to test the correct behavior of an MPLAB ICE unit.
Page 128
First, you will be warned that Verify could damage other devices if they are on the port to be verified. Make certain that you are not using MPLAB ICE with a switchbox or a pass-through and that you have selected the correct parallel port for the MPLAB ICE device.
Page 129
Verification Figure 7.3: Verify MPLAB ICE – Run Mode Tests 2001 Microchip Technology Inc. DS51159B-page 129...
Page 130
Fail counters should show the running pass and fail counts for each test. The buttons perform the following functions: • 2000 System – Checks all tests that pertain to an MPLAB ICE 2000 emulator system. • Clear Tests – Unchecks all test checkboxes.
Page 131
Figure 7.5: Port Selection Dialog - Ports Tab Figure 7.6: Port Selection Dialog - Tools Tab If you are having trouble verifying MPLAB ICE, you may wish to set up your port differently using the Ports tab. If you are having communications problems with MPLAB ICE, please refer to Chapter 8 Troubleshooting.
• Click on the "X" in the top right corner of the window Troubleshooting Verify Failures If your MPLAB ICE unit reports failures when running Verify, please check the following items: • Confirm that the MPLAB ICE unit is powered up and properly communicating with your PC.
Compatibility Mode checkbox. • In Windows 2000, the operating system might report a different address for the LPT port for MPLAB ICE than MPLAB does. If this occurs, you must change this setting in the operating system under Control Panel >...
Page 134
Control Panel>Devices and scrolling down to find mplabice. MPLAB ICE driver not loaded (Windows NT 4.0/Windows 2000) If you suspect that the MPLAB ICE driver is not being loaded correctly, check the Event Viewer. In Windows NT 4.0, the Event Viewer is under Start>Programs>Administrative Tools.
Either or both may work depending on the PC or parallel port manufacturer's implementation. Most of the time, MPLAB ICE will be able to identify and communicate with the installed parallel interface with no user intervention. Occasionally, you may encounter unique PCs that require you to configure the parallel interface so that it will correctly communicate with MPLAB ICE.
Page 136
Configuring MPLAB ICE In order to identify whether a parallel port is configured appropriately for MPLAB ICE, you will want to use the MPLAB ICE Verify routines (Tools>Verify MPLAB ICE). Errors reported using this technique may indicate a failed component, but certain interpretations can be drawn that may indicate the need to reconfigure the parallel port.
Page 137
Click the Ports tab. Click Query Port Info to cause the software to look through the known parallel ports for an MPLAB ICE system. If it finds one and can communicate adequately, the MPLAB Status bar will be updated to indicate the tool (MPLAB ICE) and the installed processor module.
Page 138
Depending on the parallel port’s implementation, one or another may actually function better with the emulator system. To determine whether the best setting is chosen, it may be useful to run Tools > Verify MPLAB ICE. If errors are reported, follow the procedures for forcing compatibility mode, or changing the port settings in the system BIOS.
Page 139
It is possible that none of the settings of the parallel port will work properly with MPLAB ICE. This is true even though other parallel port devices (e.g., printers) may function properly on the port. This is not a malfunction of MPLAB ICE.
MPLAB ICE USER’S GUIDE Appendix A. Debugging Techniques Introduction This appendix describes various debugging techniques that you may find useful when emulating with MPLAB ICE. Highlights This appendix contains the following information: • Complex Triggering Examples • Additional Debugging Techniques...
Select Debug>Complex Trigger Settings to open the Complex Trigger Settings dialog. Figure A.1: Filter Trace for ISR Time Set up the Complex Trigger Settings dialog for Filter Trace on Program Memory. Ignore FNOP Cycles should not be checked. 2001 Microchip Technology Inc. DS51159B-page 142...
Page 143
To clear all break, trace and trigger points, select Debug>Clear All Points. Select Debug>Complex Trigger Settings to open the Complex Trigger Settings dialog. Set up the Complex Trigger Settings dialog for Time Between Events on Program Memory. Click on the Start Timer Tab. 2001 Microchip Technology Inc. DS51159B-page 143...
Page 144
Figure A.4: Stop Timer for ISR Time Again, enter the address of the start of the ISR (either a numeric address or a label). In Figure A.4, the address is again irqsvc. Select Halt on Trigger. 2001 Microchip Technology Inc. DS51159B-page 144...
Page 145
Open the source code file (File>Open) to examine the code. The routine shown in Figure A.6 does not seem to be sending the right variables out. It should increment the 16-bit value of num_out and send it out to the port. 2001 Microchip Technology Inc. DS51159B-page 145...
Page 146
® MPLAB ICE User’s Guide Figure A.6: Source Code File Window Configure the trace display (Window>Trace Memory, Options>Configure) to focus on the source and destination address and data. 2001 Microchip Technology Inc. DS51159B-page 146...
Page 147
Figure A.7: Configure Trace for Variable Now set up a filtered trace to look at the routine that does the calculation. Select Debug>Complex Trigger Settings to open the Complex Trigger Settings dialog. Figure A.8: Filter Trace for Variable 2001 Microchip Technology Inc. DS51159B-page 147...
Page 148
To clear all break, trace and trigger points, select Debug>Clear All Points. Re-open the Complex Trigger Settings dialog (Debug>Complex Trigger Settings) and set two sequential events to the same address in program memory. 2001 Microchip Technology Inc. DS51159B-page 148...
Page 149
Click Apply or OK. Reset the system (Debug>System Reset) and then run your program (Debug>Run>Run, green stoplight icon on toolbar or <F9>). After it halts, bring up the Trace Memory Window (Window>Trace Memory). 2001 Microchip Technology Inc. DS51159B-page 149...
Page 150
Since this is all just initialization, more information is necessary to find the problem. Run again, and then observe the trace window at cycle 0 when the program halts. Figure A.12: Trace Display - Sequential Trigger 2 for Variable 2001 Microchip Technology Inc. DS51159B-page 150...
Page 151
To clear all break, trace and trigger points, select Debug>Clear All Points. Configure the trace display (Window>Trace Memory, Options>Configure) to focus on the source and destination address and data. 2001 Microchip Technology Inc. DS51159B-page 151...
Page 152
® MPLAB ICE User’s Guide Figure A.14: Configure Trace for Negative Variable Select Debug>Complex Trigger Settings to open the Complex Trigger Settings dialog. Figure A.15: Sequential Trigger for Negative Variable 2001 Microchip Technology Inc. DS51159B-page 152...
Page 153
Figure A.16: Trace Display - Sequential Trigger for Negative Variable The value of flags has gone from 7F to 80. Examine the cycles before (negative) and after (positive) this trigger to determine what might be misbehaving in your program. 2001 Microchip Technology Inc. DS51159B-page 153...
Page 154
Select Logic Probes and enter an 8-bit value for the trigger. When this value appears on probes EXT7:EXT0, the trigger will fire. You may enter the value as binary (ex: 00001111) or hexidecimal (ex: 0x0F). The ’x’ character means ’don’t care’. 2001 Microchip Technology Inc. DS51159B-page 154...
Page 155
You can use the pass counter to determine if a loop is executed a specific number of times. To clear all break, trace and trigger points, select Debug>Clear All Points. 2001 Microchip Technology Inc. DS51159B-page 155...
Page 156
If the program halts, the loop has executed at least as many times as indicated by the pass count. If the program does not halt, the loop is not executed that many times. 2001 Microchip Technology Inc. DS51159B-page 156...
Page 157
PICmicro MCU, an interrupt can occur when an instruction to clear interrupt flags is being fetched. The next fetch will be to branch to the ISR, but the instruction executed then will be a clear of the interrupt flags. 2001 Microchip Technology Inc. DS51159B-page 157...
• Logic Probes Power Power to the MPLAB ICE system is supplied by an external +5V power supply included with the system. The input is located on the back of the pod, as indicated in Figure B.1. The power on/off switch is also located on the back of the pod.
MPLAB ICE. Damage may occur. Parallel Port MPLAB ICE connects to the host PC via an industry standard bi-directional parallel peripheral interface (printer port). The parallel port connector is located on the rear panel of the pod. An IEEE 1284-A type connector (25-pin DSUB) on the host PC is required.
From computer B.4.1 Cable Length The PC to MPLAB ICE cable length for proper operation has been tested to be 6 feet. This length cable is shipped with MPLAB ICE. Indicator Lights Information about the indicator lights (LEDs) is listed in Table B.3.
Page 162
This LED will be on when the processor is actually running and will blink momentarily when a single step is executed. The function of this LED is the compliment of the Emulator Halt Mode LED (H). 2001 Microchip Technology Inc. DS51159B-page 162...
Processor is running. This LED will be on when the processor is halted. This LED and the Power LED should be on after MPLAB ICE has been chosen as the development mode from the MPLAB IDE. The function of this LED is the compliment of the Emulator Run Mode LED (R).
Page 164
Minimum input pulse width = 15 nsec TRGOUT The output pulse width of the filter trace is one bus cycle, which is ¼ the clock speed (PICmicro MCU devices use four clocks for each instruction). 2001 Microchip Technology Inc. DS51159B-page 164...
ICE USER’S GUIDE Appendix C. Migrating from PICMASTER Introduction Although MPLAB ICE and PICMASTER have the same basic look and feel through the MPLAB IDE, there are some differences. This appendix details those differences, showing how familiar PICMASTER tasks can be performed using MPLAB ICE.
How to Time Events With PICMASTER, events could be timed through the Stopwatch dialog. With MPLAB ICE, events are timed using the time stamp in the trace memory window. There are at least two ways to use the time stamp to time an event: 1.
Filter Trace complex trigger can be used to filter the trace. Trigger points can be obtained in MPLAB ICE by using a Filter Trace complex trigger to generate a trigger on the desired operation. Then the Trigger In/Out Settings dialog (Debug>Trigger In/Out Settings) can be used to generate an...
(high) or running (low). * To get continuous triggers from MPLAB ICE 2000 like the PICMASTER triggers, you should set up a filtered trace with Infinite Events and check the box on Trigger In/Out Dialog.
This glossary contains terms and definitions for the following tools: • MPLAB IDE, MPLAB SIM, MPLAB Editor • MPASM Assembler, MPLINK Linker, MPLIB Librarian • MPLAB CXX • MPLAB ICE, PICMASTER Emulators • MPLAB ICD • PICSTART Plus, PRO MATE programmer Terms...
Page 170
What a compiler does. See compiler. Compiler A language tool that translates a user’s C source code into machine code. MPLAB C17 and MPLAB C18 are Microchip’s C compilers for PIC17CXXX and PIC18CXXX devices, respectively. 2001 Microchip Technology Inc. DS51159B-page 170...
Page 171
Program memory contained within the emulator. Emulator Hardware that performs emulation. Emulator System The MPLAB ICE emulator system includes the pod, processor module, device adapter, cables and MPLAB Software. The PICMASTER emulator system includes the pod, device-specific probe, cables and MPLAB Software. Event A description of a bus cycle which may include address, data, pass count, external input, cycle type (fetch, R/W) and time stamp.
Page 172
Execution automatically switches to external if the program memory address is greater than the internal memory space of the PIC17CXXX or PIC18CXXX device. External Input Line (MPLAB ICE only) An external input signal logic probe line (TRIGIN) for setting an event based upon external signals.
Page 173
In-Circuit Debugger. MPLAB ICD is Microchip’s in-circuit debugger for PIC16F87X devices. MPLAB ICD works with MPLAB IDE. In-Circuit Emulator. MPLAB ICE is Microchip’s in-circuit emulator that works with MPLAB IDE. Integrated Development Environment. An application that has multiple functions for firmware development.
Page 174
Listing File A listing file is an ASCII text file that shows the machine code generated for each C source statement, assembly instruction, MPASM directive, or macro encountered in a source file. 2001 Microchip Technology Inc. DS51159B-page 174...
Page 175
One of the possible program memory configurations of the PIC17CXXX and PIC18CXXX families of microcontrollers. In microcontroller mode, only internal execution is allowed. Thus, only the on-chip program memory is available in microcontroller mode. 2001 Microchip Technology Inc. DS51159B-page 175...
Page 176
Also referred to as Opcodes. MPASM Microchip Technology’s relocatable macro assembler. MPASM is a DOS or Windows-based PC application that provides a platform for developing assembly language code for Microchip’s PICmicro microcontroller families.
Page 177
Special directives are required in the source code when generating an object file. The object file contains object code. Object File Directives Directives that are used only when creating an object file. 2001 Microchip Technology Inc. DS51159B-page 177...
Page 178
The hardware unit that provides tools for emulating and debugging firmware applications. This unit contains emulation memory, break point logic, counters, timers and a trace analyzer among some of its tools. MPLAB ICE is the newest emulator from Microchip. PICSTART Plus A device programmer from Microchip.
Page 179
The number base, hex, or decimal, used in specifying an address and for entering data in the Window > Modify command. Random Access Memory (Data Memory). Raw Data The binary representation of code or data associated with a section. 2001 Microchip Technology Inc. DS51159B-page 179...
Page 180
When released from the halt state in the emulator or MPLAB ICD mode, 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 MPLAB ICE is enabled and constantly captures all selected cycles and all break logic is enabled.
Page 181
It is an ASCII file that can be created using any ASCII text editor. Special Function Registers Registers that control I/O processor functions, I/O status, timers, or other modes or peripherals. 2001 Microchip Technology Inc. DS51159B-page 181...
Page 182
These pieces include function names, variable names, section names, file names, struct/enum/union tag names, etc. Symbols in MPLAB IDE refer mainly to variable names, function names and assembly labels. 2001 Microchip Technology Inc. DS51159B-page 182...
Page 183
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. 2001 Microchip Technology Inc. DS51159B-page 183...
Page 184
Watch Variable A variable that you may monitor during a debugging session in a watch window. Watch Window Watch windows contain a list of watch variables that are updated at each break point. 2001 Microchip Technology Inc. DS51159B-page 184...
Page 187
Status Bar ............93 Opening/Closing ........90 Step ..............93 Saving ............89 Step Over ............94 Set Up .......... 13, 42, 64 Stimulus ............182 PS/2 ..............82 Stopwatch ..........166, 182 Subroutines ..........111 2001 Microchip Technology Inc. DS51159B-page 187...
Page 188
Symbol ............182 Symbolic ............102 Unassigned Section ........184 System Button, Windows ......183 Uninitialized Data ..........184 System Components, MPLAB ICE ..... 9, 28 Uploaded Trace Lines ........124 System Reset ..........91 System Verify, MPLAB ICE ......127 Variables ..........145, 151 System Window Control .......
Page 189
Index NOTES: 2001 Microchip Technology Inc. DS51159B-page 189...
ASIA/PACIFIC Japan Microchip Technology Japan K.K. Corporate Office Australia Benex S-1 6F 2355 West Chandler Blvd. Microchip Technology Australia Pty Ltd 3-18-20, Shinyokohama Chandler, AZ 85224-6199 Suite 22, 41 Rawson Street Kohoku-Ku, Yokohama-shi Tel: 480-792-7200 Fax: 480-792-7277 Epping 2121, NSW...
Need help?
Do you have a question about the MPLAB ICE and is the answer not in the manual?
Questions and answers