User Manual (DV164131)Table of ContentsPreface5Chapter 1. Overview131.1 Introduction131.2 PICkit 3 Programmer/Debugger Defined131.3 How the PICkit 3 Programmer/Debugger Helps You151.4 PICkit 3 Programmer/Debugger Components161.5 Device and Feature Support17Chapter 2. Theory of Operation192.1 Introduction192.2 PICkit 3 vs. PICkit 2192.3 Debugger to Target Communication192.4 Communication Connections212.5 Debugging232.6 Requirements for Debugging242.7 Programming262.8 Resources Used by the Debugger26Chapter 3. Installation273.1 Introduction273.2 Installing the Software273.3 Connecting the Target273.4 Setting Up the Target Board283.5 Setting Up MPLAB IDE29Chapter 4. General Setup314.1 Introduction314.2 Starting the MPLAB IDE Software314.3 Creating a Project314.4 Viewing the Project324.5 Building the Project324.6 Setting Configuration Bits324.7 Setting the Debugger or Programmer324.8 Debugger/Programmer Limitations33Chapter 5. PICkit 3 Debug Express355.1 Introduction355.2 PICkit 3 Debug Express Kit Contents355.3 Installing the Hardware and Software35Chapter 6. Troubleshooting First Steps396.1 Introduction396.2 The 5 Questions to Answer First396.3 Top 10 Reasons Why You Can’t Debug396.4 Other Things to Consider40Chapter 7. Frequently Asked Questions (FAQs)417.1 Introduction417.2 How Does It Work417.3 What’s Wrong42Chapter 8. Error Messages458.1 Introduction458.2 Specific Error Messages458.3 General Corrective Actions48Chapter 9. Debugger Function Summary539.1 Introduction539.2 Debugging Functions539.3 Debugging Dialogs/Windows559.4 Programming Functions599.5 Settings Dialog60Chapter 10. Hardware Specification6310.1 Introduction6310.2 Highlights6310.3 Declaration of Conformity6310.4 USB Port/Power6410.5 PICkit 3 Programmer/Debugger6410.6 Standard Communication Hardware6510.7 Target Board Considerations67Appendix A. PICkit 3 Schematics69Appendix B. Operational Advisory71Glossary75Index95Worldwide Sales and Service98Size: 1.23 MBPages: 98Language: EnglishOpen manual
Data Sheet (DV164131)Table of ContentsChapter 1. Introduction111.1 Before Beginning the Lessons11Figure 1-1: MPLAB C Compiler INSTALLATION CONFIGURATION OPTIONS12Chapter 2. PIC18FXXXX Microcontroller Architectural Overview132.1 Memory Organization132.2 Program Memory132.2.1 Data Memory142.2.2 Special Function Registers142.2.3 Return Address Stack14Chapter 3. PICkit™ 3 Debug Express Lessons153.1 Lesson 1: Hello LED153.1.1 Creating the Lesson 1 Project in the MPLAB® IDE153.1.1.1 Step One: Select a device15Figure 3-1: Wizard Step One: Select PIC18F45K20 Device163.1.1.2 Step Two: Select a language toolsuite16Figure 3-2: Wizard Step Two: Select Toolsuite163.1.1.3 Step Three: Create a new project17Figure 3-3: Wizard Step Three: Create a New Project173.1.1.4 Step Four: Add existing files to your project17Figure 3-4: Wizard Step Four: Add Existing Files183.1.1.5 Summary18Figure 3-5: The Project Window19Figure 3-6: Add Files to Project20Figure 3-7: New Project Files203.1.2 Exploring the Lesson 1 Source Code20Figure 3-8: Lesson 1 “HELLO LED” Source Code213.1.3 Building and Programming the Lesson 1 Code22Figure 3-9: MPLAB IDE Output Window Build Results22Figure 3-10A: Output Window PICKIT 3 Programmer23Figure 3-10B: PICkit 3 Programmer Power Supply23Figure 3-11: Output Window PICKIT 3 Programming Results243.2 Lesson 2: Blink LED253.2.1 Opening the Lesson 2 Project and Workspace in the MPLAB IDE253.2.2 Defining Configuration Bit Settings in the Source Code25Figure 3-12: Lesson 2 “BLINK LED” Configuration Bit Definitions26Figure 3-13: MPLAB Help Topics26Figure 3-14: PIC18F45K20 Configuration263.2.3 Exploring the Lesson 2 Source Code27Figure 3-15: Lesson 2 “BLINK LED” Source Code273.2.4 Build and Program the Lesson 2 Code283.3 Lesson 3: Rotate LED293.3.1 Allocating File Register Memory29Figure 3-16: Lesson 3 Global Variable Declaration293.3.2 Allocating Program Memory30Figure 3-17: Lesson 3 Constant Data and Program Code30Figure 3-18: Program Memory “LED_LOOKUPTABLE” Array Values313.3.3 Exploring the Lesson 3 Source Code31Figure 3-19: Lesson 3 “ROTATE LED” Source Code323.3.4 Build and Program the Lesson 3 Code323.4 Lesson 4: Switch Input333.4.1 Files and the #define Directive33Figure 3-20: Header File333.4.2 Switch Debouncing34Figure 3-21: Switch Debouncing Program Flow343.4.3 Exploring the Lesson 4 Source Code34Figure 3-22: LESSON 4 “SWITCH INPUT” SOURCE CODE353.4.3.1 Variables353.4.3.2 Switch Input35Figure 3-23: ANSELH: ANALOG REGISTER 1363.4.3.3 Rotating the LEDs363.4.4 Build and Program the Lesson 4 Code363.5 Lesson 5: Using Timer0373.5.1 The PIC18F45K20 Timer0 Module37Figure 3-24: Simplified 16-bit TIMER0 Block Diagram37Figure 3-25: T0CON: TIMER0 CONTROL REGISTER383.5.2 Exploring the Lesson 5 Source Code393.5.3 Build and Program the Lesson 5 Code403.5.4 Assigning the Timer0 Prescaler403.6 Lesson 6: Using PICkit 3 Debug Express413.6.1 Resources Reserved by the PICkit 3 Debug Express413.6.1.1 General Resources413.6.1.2 Program and Data Memory Resources41Figure 3-26: RESERVED ICD FILE REGISTER LOCATIONS IN THE PIC18F45K20413.6.2 Selecting PICkit 3 as a Debugger in the MPLAB IDE423.6.3 Basic Debug Operations423.6.3.1 Halt42Figure 3-27: GREEN ARROW POINTS TO NEXT STATEMENT TO EXECUTE423.6.3.2 Step43Figure 3-28: Step Into43Figure 3-29: Step Over433.6.3.3 Run433.6.3.4 Reset43Figure 3-30: C018 START-UP LIBRARY CODE443.6.4 Using Breakpoints44Figure 3-31: SET BREAKPOINT ON LINE 11145Figure 3-32: BREAKPOINT SET45Figure 3-33: BREAKPOINT HALT46Figure 3-34: BREAKPOINTS DIALOGUE463.6.5 Watching Variables and Special Function Registers47Figure 3-35: WATCH WINDOW47Figure 3-36: WATCH VARIABLES483.7 Lesson 7: Analog-to-Digital Converter (ADC)493.7.1 PIC18F45K20 ADC Basics493.7.2 ADC Configuration and Operation49Figure 3-37: ADCON2: A/D CONTROL REGISTER 250Figure 3-38: ADCON0: A/D CONTROL REGISTER 0513.7.3 Exploring the Lesson 7 Source Code523.7.4 Build and Run the Lesson 7 Code with PICkit 3 Debug Express523.8 Lesson 8: Interrupts533.8.1 PIC18FXXXX Interrupt Architecture53Figure 3-39: SIMPLIFIED INTERRUPT LOGIC53Figure 3-40: PRIORITY INTERRUPT EXECUTION FLOW543.8.2 Exploring the Lesson 8 Source Code54Figure 3-41: DEFINE INTERRUPT VECTORS55Figure 3-42: INTERRUPT SERVICE FUNCTIONs55Figure 3-43: LESSON 8 INTERRUPT INITIALIZATIONS56Figure 3-44: LESSON 8 INTERRUPT SFRS573.8.3 Build and Run the Lesson 8 Code with PICkit 3 Debug Express573.9 Lesson 9: Internal Oscillator583.9.1 The Internal Oscillator Block58Figure 3-45: SIMPLIFIED INTERNAL OSCILLATOR BLOCK DIAGRAm583.9.2 Configuring the Internal Oscillator59Figure 3-46: OSCCON: OSCILLATOR CONTROL REGISTER59Figure 3-47: OSCTUNE: OSCILLATOR TUNING REGISTER603.9.3 Exploring the Lesson 9 Source Code61Figure 3-48: SOURCE CODE BACKGROUND LOOp613.9.4 Build and Run the Lesson 9 Code with PICkit 3 Debug Express613.10 Lesson 10: Using Internal EEPROM623.10.1 Reading a data byte from EEPROM62Figure 3-49: EECON1: EEPROM CONTROL REGISTER 162Figure 3-50: DATA EEPROM READ633.10.2 Writing a data byte to EEPROM63Figure 3-51: DATA EEPROM WRITe643.10.3 Exploring the Lesson 10 Source Code643.10.4 Build and Run the Lesson 10 Code with PICkit 3 Debug Express643.11 Lesson 11: Program Memory Operations65Figure 3-52: PROJECT CODE MODEL SETTINGS663.11.1 Erasing and Writing Flash Program Memory67Figure 3-53: EXAMPLE PROGRAM MEMORY WRITE FUNCTIOn693.11.2 Protecting Program Memory in the Configuration Bits.693.11.3 Exploring the Lesson 11 Source Code with PICkit 3 Debug Express70Figure 3-54: STRINGS IN PROGRAM MEMORY70Figure 3-55: BREAKPOINT ON POINTER ASSIGNMENT70Figure 3-56: ERASED 0x0100 TO 0x013F71Figure 3-57: PROGRAM MEMORY WRITE RESULTS713.12 Lesson 12: Using the CCP Module PWM723.12.1 PWM Overview72Figure 3-58: EXAMPLE PWM DUTY CYCLES723.12.2 Using the CCP Module72Figure 3-59: T2CON: TIMER2 CONTROL REGISTEr73Figure 3-60: SIMPLIFIED PWM BLOCK DIAGRAm74Figure 3-61: CCPxCON: CCPx CONTROL REGISTER753.12.3 Exploring the Lesson 12 Source Code753.12.4 Build and Run the Lesson 12 Code with PICkit 3 Debug Express76Appendix A. Schematics77Worldwide Sales78Size: 3.19 MBPages: 78Language: EnglishOpen manual
User Manual (DV164131)Table of ContentsPICkit 3 In-Circuit Debugger/Programmer User’s Guide For MPLAB X IDE1EU Declaration of Conformity3Table of Contents5Preface7INTRODUCTION7DOCUMENT LAYOUT8CONVENTIONS USED IN THIS GUIDE9DOCUMENTATION CONVENTIONS9RECOMMENDED READING10Part 1 – Getting Started11Chapter 1. About the In-Circuit Debugger/Programmer131.1 Introduction131.2 PICkit 3 In-Circuit Debugger/Programmer Defined13Figure 1-1: PICkit™ 3 MCU In-Circuit Debugger/Programmer141.2.1 Lanyard Loop141.2.2 USB Port Connection141.2.3 Pin 1 Marker141.2.4 Programming Connector15Figure 1-2: PICKIT™ 3 Programmer Connector PinOut151.2.5 Indicator LEDs151.2.6 Push Button151.3 How the PICkit 3 In-Circuit Debugger/Programmer Helps You161.4 PICkit 3 In-Circuit Debugger/Programmer Components16Figure 1-3: Basic Debugger System16Chapter 2. Operation172.1 Introduction172.2 Tools Comparison18Table 2-1: Debug Tools Comparison182.3 PICkit 3 vs. PICkit 2182.4 Debugger to Target Communication19Figure 2-1: Standard Debugger System – Device with On-Board ICE Circuitry19Figure 2-2: Standard Debugger System – ICE Device202.5 Communication Connections212.5.1.1 Using Single In-Line Connector21Table 2-2: Target Connector Pinout212.5.1.2 Using An Adapter21Figure 2-3: Standard RJ-11 Connection at Target21Figure 2-4: Standard Connection Target Circuitry22Figure 2-5: Improper Circuit components232.6 Debugging24Figure 2-6: Proper connections for programming242.7 Requirements for Debugging25Figure 2-7: PICkit™ 3 Debugger Ready for Debugging262.8 Programming272.9 Resources Used by the Debugger27Chapter 3. Debugger Usage293.1 Introduction293.2 Installation and Setup293.3 Common Debug Features303.4 Connecting the Target30Figure 3-1: Insert Communications and USB/Power Cables303.5 Setting Up the Target Board313.5.1 Using Production Devices313.5.2 Using ICE Devices31Figure 3-2: Using an ICD Header Board323.5.4 Powering the Target323.6 Setting Up MPLAB X IDE333.7 Starting and Stopping Debugging333.8 Viewing Processor Memory and Files33Chapter 4. PICkit 3 Debug Express354.1 Introduction354.2 PICkit 3 Debug Express Kit Contents354.3 Installing the Hardware and Software354.3.1 Reserved Resources35Figure 4-1: Connecting the Demo Board to the PICkit™ 336Chapter 5. PICkit 3 Programmer-To-Go375.1 Introduction375.2 USB Power for PICkit 3 Programmer-To-Go375.2.1 Power Requirements375.3 PICkit 3 Programmer-To-Go Supported Devices38Table 5-1: Programmer-To-Go Supported Devices385.4 Setting up PICkit 3 for Programmer-To-Go Operation395.4.1 Set Up Programmer-to-Go39Figure 5-1: PICkit 3 Project Properties39Figure 5-2: Name the Image40Figure 5-3: Programmer To Go Tab405.4.2 Download to PICkit 3 Complete41Figure 5-4: Download to PICkit 3415.5 Using PICkit 3 Programmer-To-Go42Table 5-2: Programmer-To-Go Operation Feedback Codes425.6 Exiting Programmer-To-Go Mode43Part 2 – Troubleshooting45Chapter 6. Troubleshooting First Steps476.1 Introduction476.2 The 5 Questions to Answer First476.3 Top 10 Reasons Why You Can’t Debug476.4 Other Things to Consider48Chapter 7. Frequently Asked Questions (FAQs)497.1 Introduction497.2 How Does It Work497.3 What’s Wrong50Chapter 8. Error Messages538.1 Introduction538.2 Specific Error Messages538.3 General Corrective Actions54Chapter 9. Engineering Technical Notes (ETNs)57Part 3 – Reference59Appendix A. Hardware Specification61A.1 Introduction61A.2 Highlights61A.3 Declaration of Conformity61A.4 USB Port/Power62A.5 PICkit 3 In-Circuit Debugger/Programmer62A.6 Standard Communication Hardware63Figure A-1: 6-Pin Standard Pinout63A.6.2.1 Modular Connector Specification64Figure A-2: Modular Connector Pinout of Target Board64A.6.2.2 Modular Plug Specification65A.6.2.3 Modular Cable Specification65A.7 Target Board Considerations65Appendix B. PICkit 3 Schematics67Figure B-1: PICkit™ 3 Schematic Diagram (Page 1 of 2)67Figure B-2: PICkit™ 3 Schematic Diagram (Page 2 of 2)68Appendix C. Revision History69Glossary71Index91Worldwide Sales and Service94Size: 2.36 MBPages: 94Language: EnglishOpen manual