Home

PICkit 2 Microcontroller Programmer USER'S GUIDE

image

Contents

1. d gen AS gen gx payeindod jou 9 9 pue ZC 3L0N DS51553B page 51 2007 Microchip Technology Inc PICkit 2 MICROCONTROLLER PROGRAMMER SCHEMATIC DIAGRAM PAGE 2 OF 2 FIGURE A 2 E ae 191 HION 80 SION UNO eza voor eza pose LWW 2 CT EH a OH VAA ii vza aan aan 1917004 7 lt ovada aan Ka e SOGELENN yovaaasa lt n avaasor e ii ii HT94S91 A xnv g nz Toos mir asol _ a F sal za voseLaww N _ E sto D n ran ma oly 906 LANN Ki waa oey so vsLva ed 1VadS91 vee vot Hoge 8 8 ozy D n Not gu ae 20 Se as T 7 ra asi Ast oy OF voze d uo sum we i A La SpL PEN 000LSOHZ N uo sur UBIH ILAE 1a ra OILY SOGELENN lt i azo ance seu o lt Tor ne sl UN LT lt osy S Masai e a DE Dot O S ei _ EDEN D D EN N LOL Go ofa BH Wun Si i s 2029004 Di sn OILY fas ozy 906 Low ado LL B Si D I is X A vee vol EH gan ZS SALSA PICkit 2 MCU Programmer User s Guide 2007 Microchip Technology Inc DS51553B page 52 PICKIT 2 MCU PROGRAMMER USER S GUIDE NOTES 2007 Microchip Technology Inc DS51553C page 53 MICROCHIP WORLDWIDE SALES AND SERVICE AMERICAS Corporate Office 2355 West Chandler Blvd Chandler AZ 85224 6199 Tel 480 792 72
2. v Enabled Hex Only v Source None Empty Erased Memory Source 0000 3FFF 3FFF 3FFF 3FFF 3FFF 0008 3FFF 3FFF 3FFF 3FFF 3FFF 0010 3FFF 3FFF 3FFF 3FFF 3FFF 0018 3FFF 3FFF 3FFF 3FFF 3FFF 0020 3FFF 3FFF 3FFF 3FFF 3FFF 0028 3FFF 3FFF 3FFF 3FFF FFF 0030 3FFF 3FFF 3FFF 3FFF FFF Program Memory 0038 3FFF 3FFF 3FFF 3FFF 3FFF 0040 3FFF 3FFF 3FFF 3FFF 3FFF 0048 3FFF 3FFF 3FFF 3FFF 3FFF 0050 3FFF 3FFF 3FFF 3FFF 3FFF 0058 3FFF 3FFF 3FFF 3FFF 3FFF EEPROM Data Import Hex File v Enabled Hex Only Write Device 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 10 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF Export Hex File 20 FF FF FF FF FF FF FF FF FFF FF FF FF FF FF FF SZ 30 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ze PICkit 2 EEPROM Data Memory DS51553C page 10 2007 Microchip Technology Inc PICkit 2 Programmer Overview 1 6 1 Menu Bar The menu bar selects various functions of the PICkit 2 Programming Software A summary of the functions are FILE e Import Hex Import a hex file for programming The hex file format INHX32 is supported e Export Hex Export a hex file read from a device The hex file is created in the INHX32 format e Exit Exit the program DEVICE FAMILY Select a device family to search for a connected device in that family Selecting the device family of the current part will clear all device data Some families whic
3. 3 2 1 If the VPP pin is used as a MCLR pin The application circuit typically is connected to a pull up resistor capacitor circuit as recommended in the device data sheet Care must be taken so that the VPP voltage slew rate is not slowed down and exceeds the rise time in the programming specification typically 1 us If a Supervisory circuit or a push button is interfaced to the MCLR pin it is recommended that they be isolated from the VPP voltage by using a Schottky type diode or limiting resistor as shown in Figure 3 1 For more information about using supervisory circuits with ICSP see Application Note AN820 System Supervisors in ICSP Architectures DS00820 3 2 2 If the VPP pin is used as an I O port pin The application circuit that connects to the I O pin may not be able to handle the 12V voltage It is recommended to use a Schottky type diode or limiting resistor as shown in Figure 3 1 to isolate the circuitry 3 3 ISOLATE ICSPCLK OR PGC AND ICSPDAT OR PGD PINS The ICSPCLK or PGC and ICSPDAT or PGD pins need to be isolated from the application circuit to prevent the programming signals from being affected by the application circuitry ICSPCLK or PGC is a unidirection synchronous serial programming clock line from the programmer to the target ICSPDAT or PGDis a bidirectional synchronous serial programming data line If the design permits dedicate these pins for ICSP However if the application circuit requires tha
4. MCU The goal is to keep the ICSP signals within the level and slew rate specifications for successful programming DS51553C page 28 2007 Microchip Technology Inc MICROCHIP pickit 2 MCU PROGRAMMER USER S GUIDE Chapter A PICkit 2 Debug Express 4 1 INTRODUCTION The PICkit 2 Microcontroller Programmer allows in circuit debugging on selected PIC Microcontroller Units MCUs In circuit debugging allows the designer to run examine and modify the program while the PIC MCU is embedded in the hardware This greatly assists the designer in debugging the firmware and hardware together The Debug Express software interacts with the MPLAB IDE software to run stop and single step through programs One breakpoint can be set and the processor can be reset Once the processor is stopped the register s contents can be examined and modified Note Debug Express requires MPLAB IDE 7 50 version or later Note Debug Express requires 4 7k Ohm pull down resistors on ICSPCLK and ICSPDAT Newer PICkit 2 Microcontroller Programmers that have a Red button have the pull downs internally Older PICkit 2 Microcontroller Programmers that have a Black button require that the pull downs be added on the target board 4 1 1 Supported Devices For alist of current devices supported by PICkit 2 Debug Express see the Readme for PICkit 2 htm file in the Readmes subdirectory of the MPLAB IDE installation dir
5. MCU assembler MPASM assembler linker MPLINK linker and librarian MPLIB librarian README for PICkit 2 Debug Express For the latest information on using the PICkit 2 Debug Express read the Readme for PICkit 2 htm file an ASCII text file in the Readmes subdirectory of the MPLAB IDE installation directory The Readme file contains updated information and known issues that may not be included in this user s guide Readme Files For the latest information on using other tools read the tool specific Readme files in the Readmes subdirectory of the MPLAB IDE installation directory The Readme files contain update information and known issues that may not be included in this user s guide KEEN EEN DS51553C page 4 2007 Microchip Technology Inc 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 e Product Support Data sheets and errata application notes and sample programs design resources user s 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
6. The user will also be warned that the hex file is larger than the selected device if the hex file contains memory locations that do not exist in the current device Any data for non existent locations will not be imported FIGURE 2 8 IMPORT HEX FILE S PICKit 2 Programmer Device Family Programmer Tools Help Import Hex Export Hex Configuration 3FFF 0700 Exit Checksum 9187 Hex file sucessfully imported KX MICROCHIP YDD PICkit 2 Read Write Verify Erase Blank Check Sc z Program Memory v Enabled Hex Only v Source C Lessons 0 Reversible Reversible HEX 0000 1683 30FF 0085 3001 0086 0188 3010 009F amp 2 3 5 Write After a device family has been selected and a hex file has been imported the target PIC MCU can be programmed by clicking on the Write button The PIC MCU will be erased and programmed with the hex code previously imported The status of the Write operation is displayed in the status bar located under the Device Configuration window The device will be erased prior to programming The PICkit 2 Microcontroller Programmer uses the bulk erase method that requires a minimum VDD The user will be warned if VDD is below the minimum for the connected device If the write is successful the status bar turns green and displays Programming Successful as shown in Figure 2 9 2007 Microchip Technology Inc
7. DS51553C page 19 PICkit 2 MCU Programmer User s Guide FIGURE 2 9 WRITE SUCCESSFUL STATUS PICkit 2 Programmer File Device Family Programmer Tools Help Midrange Configuration Device PIC16F887 Configuration 30F4 0700 User IDs FF FF FF FF Checksum 9187 Se S Mco Oui VOD PICKit2 On o Read Write Verify Erase Blank Check MCLR Program Memory v Enabled Hex Only v Source C Lessons 0 Reversible Reversible HEX 0000 1683 30FF 0085 3001 0086 0188 3010 009F A If the write fails the status bar turns red and displays Programming Failed as shown in Figure 2 10 This error indicates that the data was corrupted during the programming sequence If this error is displayed try writing the program to the device again If the error continues see Chapter 5 Troubleshooting for assistance FIGURE 2 10 WRITE ERROR STATUS PICkit 2 Programmer File Device Family Programmer Tools Help Midrange Configuration Device PIC16F887 Configuration 30F4 0700 User IDs FF FF FF FF Checksum 9187 Programming failed at Program Memory address AN MICROCHIP Ox000000 VDD PICKit2 On a Read Write Verify Erase Blank Check MCLR Program Memory v Enabled Hex Only v Source C Lessons 0 Reversible Reversible HEX 0000 1683 30FF 0085 3001 0086 0188 3010 009F
8. regardless of the VDD PICkit 2 On check box state 2007 Microchip Technology Inc DS51553C page 17 PICkit 2 MCU Programmer User s Guide CAUTION The USB port current limit is set to 100 mA If the target plus PICkit 2 Microcontrol ler Programmer exceed this current limit the USB port will turn off The target may be powered externally if more power is required FIGURE 2 5 ENABLE TARGET POWER Midrange device found AN MICROCHIP VDD PICkit 2 v On 5 Read Write Verify Erase Blank Check MCLR x If a short or heavy current load is detected on the PICkit 2 Microcontroller Program mer supplied VDD then the user will receive an error as in Figure 2 6 and VDD will be automatically disabled To avoid heavy current load errors it is recommended to keep the target current consumption below 25 mA Large VDD capacitances should also be avoided as they slow down the VDD risetime The allowed VDD rise time is 500 us or less FIGURE 2 6 VDD ERROR Midrange device found MICROCHIP S PICkit 2 Error VDD PICkit 2 PICkit 2 VDD voltage level error v On 45 Read Write Verify Check target amp retry operation MCLR Program Memory v Enabled Hex Only v The target device may also be powered externally By default the PICkit 2 Program
9. 12 bit core Flash device family is selected the user must select the specific device from the device drop down box as shown in Figure 2 4 A Ensure that the correct Baseline Flash device has been selected These devices do not contain a device ID to confirm device selection Choosing the wrong Baseline Flash device may cause an erasing of the OSCCAL value stored in the last memory location FIGURE 2 4 SELECT BASELINE FLASH DEVICE PICkit 2 Programmer File Device Family Tools Help Baseline Configuration Device Select Part Configuration 0000 Select Part UserIDs Pict oF 200 _ PICIOF202 Checksum PICIOF204 PIC10F206 PIC10F220 PIC10F222 AN MICROCHIP PIC12F508 PIC12F509 i PIC12F510 DES Geng S 7 PIC16F505 d v PIC16F506 MCLR PICIBF54 Program Met pic6r57 PIC16F59 None Empty Erased 2 3 3 Target Power The PICkit 2 Microcontroller Programmer can supply power to the target To enable power to the target device check the VDD PICkit 2 On check box as shown in Figure 2 5 The voltage supplied to the target may be adjusted before or after enabling power by adjusting the voltage box Note When starting the PICkit 2 Microcontroller Program target power defaults to off Note If a target power supply is not detected the PICkit 2 Microcontroller Programmer will always supply power to the target during programming
10. 3 If a device has EEPROM data memory the Enabled checkbox next to Program Memory and EEPROM Data memory will become available The checkboxes may be used to select which memory regions programming opera tions will affect Refer to Table 2 1 for a description of how programming operations are affected by the checkboxes Erase and Blank Check always operate on all memory regions During a Write regions that are unaffected will remain unchanged in the device For example if Program Memory is unchecked while EEPROM Data is checked then a Write operation will only write EEPROM Data while Program Memory User IDs and Configuration Words in the device will remain unchanged Erase and Blank Check will still operate on all memory regions If Program Memory is checked while EEPROM Data is unchecked then a Write operation will program Program Memory User IDs and Configuration Words while EEPROM Data in the device will remain unchanged Note that due to programming constraints in some devices the PICkit 2 Microcontrol ler Programmer Application will read and re write EEPROM data memory during a write to preserve it Erase and Blank Check will still operate on all memory regions DS51553C page 20 2007 Microchip Technology Inc Getting Started It is not allowed to have both memory regions unchecked TABLE 2 1 MEMORY REGION SELECTION Program EEPROM Data S F Memory Enabled Enabled Wr
11. CONFIGURATION BIT SETTINGS W Configuration Bits Address Category Setting Oscillator Internal RC No Clock Watchdog Timer Off Power Up Timer On Master Clear Enable NCLR is external Code Protect Off Data EE Read Protect Off Brown Out Detect BOD and SBOREN disabled Internal External Switch Over Mode Disabled Monitor Clock Fail safe Disabled Low Voltage Program Disabled Self Write Enable No protection Brown Out Reset Sel Bit Brown out at 2 1V 4 2 8 Loading Program Code for Debugging e Select Debugger gt Select Tool gt PICkit 2 to select the PICkit 2 Microcontroller Programmer as the debug tool e Select Debugger gt Program to program the 16F887Demo asm file into the PIC16F887 on the 44 Pin Demo Board FIGURE 4 19 aa PIC16F887 Debug Demo MPLAB IDE v7 50 File Edit View Project Ree Programmer Tools Configure Window Help Select Tool gt ay D g Release ch GG fe amp Clear Memory gt Run F9 Animate Step Into F7 Step Over F8 Build Initializing PICKit 4 Version Con Found PICkit 2 Q ion 2 1 0 Target power not Reset gt om PICkit 2 PICI 6F887 found Breakpoints F2 PICkit 2 Ready Read Read EEDATA Connect Download OS Settings Programming will only take a few seconds During programming the PICkit 2 tab of the Output dialog window will display the current phase of operation When program ming is complete the dialog should look similar
12. Incorporated in the U S A Analog for the Digital Age Application Maestro CodeGuard dsPICDEM dsPICDEM net dsPICworks ECAN ECONOMONITOR FanSense FlexROM fuzzyLAB In Circuit Serial Programming ICSP ICEPIC Linear Active Thermistor Mindi MiWi MPASM MPLIB MPLINK PICkit PICDEM PICDEM net PICLAB PICtail PowerCal Powerlnfo PowerMate PowerTool REAL ICE rfLAB rfPICDEM Select Mode Smart Serial SmartTel Total Endurance UNI O WiperLock and ZENA are trademarks of Microchip Technology Incorporated in the U S A and other countries SQTP is a service mark of Microchip Technology Incorporated in the U S A All other trademarks mentioned herein are property of their respective companies 2007 Microchip Technology Incorporated Printed in the U S A All Rights Reserved gt Printed on recycled paper Microchip received ISO TS 16949 2002 certification for its worldwide headquarters design and wafer fabrication facilities in Chandler and Tempe Arizona Gresham Oregon and Mountain View California The Company s quality system processes and procedures are for its PIC MCUs and dsPIC DSCs KEELOQ code hopping devices Serial EEPROMs microperipherals nonvolatile memory and analog products In addition Microchip s quality system for the design and manufacture of development systems is ISO 9001 2000 certified DS51553C page ii 2007 Microchip Technology Inc MICROCHIP PiCkit 2 MCU PROGRAMME
13. be edited in the window The check box next to the EEPROM Data window controls whether the EEPROM Data memory is written read and verified If the box is checked then the device EEPROM will be overwritten with the window data If the box is not checked then the device EEPROM will not be erased or altered during a Write Device operation The checkbox does not affect Erase Device or Blank Check operations Both memory window checkboxes may not be cleared at the same time 2007 Microchip Technology Inc DS51553C page 13 PICkit 2 MCU Programmer User s Guide NOTES DS51553C page 14 2007 Microchip Technology Inc MICROCHIP PiCkit 2 MCU PROGRAMMER USER S GUIDE Chapter 2 Getting Started 2 1 INTRODUCTION This chapter gives instruction on how to get started using the PICkit 2 Microcontroller Programmer to program Flash based PIC microcontroller units MCU For information on how to use the PICkit 2 Microcontroller Programmer with In Circuit Serial Programming ICSPTM refer to Chapter 3 PICkit 2 Programmer and ICSPTM For information on how to update the PICkit 2 Programmer operating system refer to Chapter 6 Updating the PICkit 2 Programmer Operating System 2 2 INSTALLING THE PICkit 2 PROGRAMMING SOFTWARE Insert the PICkit Starter Kit CD ROM into the CD ROM drive In a few moments the introductory screen should be displayed Follow the directions on the screen
14. not be able to supply 4 75V on VDD Program these parts using an external 5 0V power supply Some PIC18F parts require significant bypass capacitance on VDD Try increasing the total bypass capacitance up to 10 uF PIC18F_J_ parts PIC24 and dsPIC DSC parts require a 4 7 uF capacitor on the VDDCORE VCAP pin in order to function properly If not using a separate regulator to supply VDDCORE ensure that the ENVREG pin is tied to VDD Debug Express Connection Problems Question While using PICkit 2 Programmer as a debugger frequently get the error Unable to Enter Debug Mode when programming the device What s wrong Answer During debugging the ICSPCLK and ICSPDAT signal lines must be completely isolated from other circuitry in the application PICkit 2 Microcontroller Program mers with a black push button require that 4 7k Ohm pull down resistors be added from both ICSPCLK and ICSPDAT to GND Newer PICkit 2 Microcontroller Programmers with a red push button have the pull downs internally DS51553C page 48 2007 Microchip Technology Inc MICROCHIP pickitTM 2 MCU PROGRAMMER USER S GUIDE Chapter 6 Updating the PICkit 2 Programmer Operating System 6 1 INTRODUCTION This chapter describes how to update the PICkit 2 Microcontroller Programmer s operating system 6 2 UPDATING THE PICkit 2 MICROCONTROLLER PROGRAMMER To update the PICkit 2 Microcontroller Programmer Operating System comple
15. 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 DEVELOPMENT SYSTEMS CUSTOMER CHANGE NOTIFICATION SERVICE Microchip s customer notification service helps keep customers current on Microchip products Subscribers will receive e mail notification whenever there are changes updates revisions or errata related to a specified product family or development tool of interest To register access the Microchip web site at www microchip com click on Customer Change Notification and follow the registration instructions The Development Systems product group categories are e Compilers The latest information on Microchip C compilers and other language tools These include the MPLAB C18 and MPLAB C30 C compilers MPASM and MPLAB ASM30 assemblers MPLINK and MPLAB LINK30 object linkers and MPLIB and MPLAB LIB30 object librarians Emulators The latest information on Microchip in circuit emulators This includes the MPLAB ICE 2000 and MPLAB ICE 4000 In Circuit Debuggers The latest information on the Microchip in circuit debugger MPLAB ICD 2 MPLAB IDE The latest information on Microchip MPLAB IDE the Windows Integrated Development Environment for development systems tools This list is focused on the MPLAB IDE MPLAB SIM simulator MPLAB IDE Project M
16. previous steps in the Project Wizard Click Finish FIGURE 4 13 PROJECT SUMMARY Project Wizard Summary Click Finish to create the project with these parameters Project Parameters Device PIC16F887 Toolsuite Microchip MPASM Toolsuite File C Program Files Microchip PICkit 2 v2 DBE A new workspace will be created and the new project added to that workspace lt Back If Cancel Help 4 2 5 PIC16F887 Debug Demo Project After completing the project setup and exiting the Project Wizard the Project Window will display in the MPLAB IDE desktop window as shown in Figure 4 14 K E E ee wa AA ELA DS51553C page 36 2007 Microchip Technology Inc PICkit 2 Debug Express FIGURE 4 14 PROJECT WINDOW MI PIC16F887 Debug Dem MISIRI a LI PIC16F887 Debug Demo mcp a Source Files 16F887Demo asm E Header Files E object Files D Library Files E Linker Scripts E other Files P Symbols If needed additional files can be added to the project using the Project Window Right click on any of the files or folders in the Project Window tree to display a pop up window with additional options for adding or removing files FIGURE 4 15 ADDING AND REMOVING FILES MI PIC16F887 Debug Dem MISIRI a LI PIC16F887 Debug Demo mcp 3 BER 12 16F8t C3 Header Fi Filter E object Files D Library Files E Linker Scripts E other Files O Fil
17. to Figure 4 20 Note The debug executive code is automatically programmed in the upper program memory of the PIC16F887 target device for the PICkit 2 debug functions Debug code must be programmed into the target PIC MCU to use the in circuit debugging capabilities of the PICkit 2 Programmer eh 2007 Microchip Technology Inc DS51553C page 39 PICkit 2 MCU Programmer User s Guide FIGURE 4 20 OUTPUT WINDOW PICkit 2 TAB Build Version Control Find in Files PICKit 2 Initializing PICKit 2 version 0 0 2 9 Found PICkit 2 Operating System Version 2 1 0 Target power not detected Powering fram PICkit 2 PIC16F88 found Rev 0x2 PICkit 2 Ready Programming Target 11 16 2006 4 50 09 PM Erasing Target Programming Program Memory 0x0 Ox4F Verifying Program Memory 0x0 Ox4F Programming Debug Executive 0x 1F00 0x1 FFF Verifying Debug Executive 0x1 F00 0x1 FFF Programming Debug Vector Verifying Debug Vector Programming Configuration Memory Verifying Configuration Memory Debug mode entered DE Version 1 0 4 PICkit 2 Ready 4 2 9 PIC16F887 Debug Demo The PICkit 2 Microcontroller Programmer executes in either Real Time or Step mode Real Time execution occurs when the PIC16F887 on the 44 Pin Demo Board is in MPLAB IDE s Run mode Step mode execution can be accessed after the processor is halted The following toolbar buttons can be used for quick acc
18. 00 Fax 480 792 7277 Technical Support http support microchip com Web Address www microchip com Atlanta Duluth GA Tel 678 957 9614 Fax 678 957 1455 Boston Westborough MA Tel 774 760 0087 Fax 774 760 0088 Chicago Itasca IL Tel 630 285 0071 Fax 630 285 0075 Dallas Addison TX Tel 972 818 7423 Fax 972 818 2924 Detroit Farmington Hills MI Tel 248 538 2250 Fax 248 538 2260 Kokomo Kokomo IN Tel 765 864 8360 Fax 765 864 8387 Los Angeles Mission Viejo CA Tel 949 462 9523 Fax 949 462 9608 Santa Clara Santa Clara CA Tel 408 961 6444 Fax 408 961 6445 Toronto Mississauga Ontario Canada Tel 905 673 0699 Fax 905 673 6509 ASIA PACIFIC Asia Pacific Office Suites 3707 14 37th Floor Tower 6 The Gateway Habour 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 Fuzhou Tel 86 591 8750 3506 Fax 86 591 8750 3521 China Hong Kong SAR Tel 852 2401 1200 Fax 852 2401 3431 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 Shunde Tel 86 757 2839 5507 Fax 86 757 283
19. 41 PICkit 2 MCU Programmer User s Guide FIGURE 4 22 ADRESH REGISTER VALUE M C 16F887Demo asm e9 bsf ADCO DONE start conversion 30 btfsc AD DONE this bit will change to zero when t 91 goto 1 92 movt ADRESH w Copy the AZD result to the delay lo bs movie De 1 sa 95 AZDDelayLoop Ge incfsz Waste time 97 goto The Inner loop tak instructions 38 incfsz er loop t and additional 29 goto 2 instructions 100 call it a two te f a second 101 6 7 Adjust the POT and continue the program continue by selecting Debug gt Run The program will run through the loop and halt Mouse over ADRESH again the A D result has not changed Thus it seems the A D conversion is not working The A D conversion initialization and setup occurs at the beginning of the program FIGURE 4 23 PROGRAM HALTED M C 16F88 Demo asm Si MainLoop ez movf Display w Copy the display to the LEDs 83 movwf PORTD SA nop wait total of SuS for AZD amp to se es nop wait lus 86 nop wait lus 87 nop wait lus es nop wait lus 89 bsf ADCONO G0 DONE start conversion 90 btfsc ADCONO GO_DONE this bit will change to zero when t 91 goto 1 92 movt ADRESH w Copy the AZD result to the delay lo Sa movwf Delay l 94 95 36 Waste time 97 The Inner 28 h 29 100 D two tenths of a 101 102 movlw 13 Delay another 10m plus whatever wa 103 mov
20. 9 5571 China Wuhan Tel 86 27 5980 5300 Fax 86 27 5980 5118 China Xian Tel 86 29 8833 7250 Fax 86 29 8833 7256 ASIA PACIFIC India Bangalore Tel 91 80 4182 8400 Fax 91 80 4182 8422 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 Gumi Tel 82 54 473 4301 Fax 82 54 473 4302 Korea Seoul Tel 82 2 554 7200 Fax 82 2 558 5932 or 82 2 558 5934 Malaysia Penang Tel 60 4 646 8870 Fax 60 4 646 5086 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 572 9526 Fax 886 3 572 6459 Taiwan Kaohsiung Tel 886 7 536 4818 Fax 886 7 536 4803 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 12 08 06 DS51553C page 54 2007 Mi
21. E DEMO 6F887DEMO ASM 65 Regi Message 302 C PROGRAM FILES MICROCHIPAPICKIT 2 VADBE DEMO 6F887DEMO ASM 67 Regi Message 302 C PROGRAM FILES MICROCHIPAPICKIT 2 VADBE DEMO 16F887DEMO ASM 71 Regi Loaded C Program Files Microchip PICkit 2 v2 DBE Demo 16F887Demo COD BUILD SUCCEEDED Thu Nov 16 16 37 55 2006 4 2 7 Setting Debug Options Before debugging can begin the device Configuration bits need to be selected 4 2 7 1 CONFIGURATION BITS The Configuration bits that are to be programmed into the device are set from within the program These bits can be verified using the Configuration Bits dialog window e Select Configure gt Configuration Bits e To change the setting for a category double click on the text in the Setting column and select the appropriate setting for the corresponding category The following Configuration bits should be set for this tutorial Config1 Oscillator Internal RC No Clock Watchdog Timer Off Power Up Timer On Master Clear Enable MCLR is external Code Protect Off Data EE Protect Off Brown Out Detect BOD and SBOREN Disabled Internal External Switch Over Mode Disabled Monitor Clock Fail safe Disabled Low Voltage Program Disabled Config 2 e Self Write Enable No Protection e Master Brown out Reset Sel Bit Brown out at 2 1V DS51553C page 38 2007 Microchip Technology Inc PICkit 2 Debug Express FIGURE 4 18
22. F FF FF FF FF FF Export Hex File FF FF FF FF FF FF FF FF FF FF FF Se FF FF FF FF FF FF FF FF FF FF FF PICkit 2 2 3 1 Connecting to the Device The PICkit 2 Microcontroller Programmer is capable of programming a variety of Flash based Microchip PIC microcontrollers When the PICkit 2 Programmer software application is first opened it will attempt to identify a connected device by the device ID To connect to a device once the application is already running select the device family by clicking on the Device Family menu as shown in Figure 2 2 FIGURE 2 2 SELECT DEVICE FAMILY PICkit 2 Programmer Device Family Programmer Tools Help Baseline Midrange PIC18F Configuration 3FFF 0003 PIC18F_J_ PIC24 2 3 2 Device Identification The PICkit 2 Microcontroller Programmer will automatically read the device ID word from the connected PIC MCU and display it in the Configuration window as shown in Figure 2 3 At any time the device family may be selected to search for connectivity to a device in that family DS51553C page 16 2007 Microchip Technology Inc Getting Started FIGURE 2 3 IDENTIFY DEVICE 5 PICkit 2 Programmer File Device Family Programmer Tools Help Midrange Configuration Device PIC16F887 Configuration 3FFF 0700 User IDs FF FF FF FF Checksum 26FF Midrange device found KX MICROCHIP If the Baseline
23. Import Hex Write Device button again If an error is encountered during hex file importing or device programming the PICkit 2 Microcontroller Programmer will automatically exit this feature mode DS51553C page 22 2007 Microchip Technology Inc Getting Started FIGURE 2 12 AUTO IMPORT HEX WRITE DEVICE BUTTON Write Device Read Device Export Hex File Pickit 2 FIGURE 2 13 AUTO IMPORT WRITE FEATURE ACTIVE Auto Import Hex Write Device Pickit 2 2 3 13 Read Device Export Hex File Button When clicked this button will read the target device and open an Export Hex File dialog ch 2007 Microchip Technology Inc DS51553C page 23 PICkit 2 MCU Programmer User s Guide NOTES DS51553C page 24 2007 Microchip Technology Inc MICROCHIP PiCkit 2 MCU PROGRAMMER USER S GUIDE Chapter 3 PICkit 2 Programmer and ICSPTM 3 1 INTRODUCTION The PICkit 2 Microcontroller Programmer can program PIC microcontrollers that are installed in an application circuit using In Circuit Serial Programming ICSP In Circuit Serial Programming ICSP requires five signals VPP Programming Voltage when applied the device goes into Programming mode ICSPCLK or PGC Programming Clock a unidirectional synchronous serial clock line from the programmer to the target e ICSPDAT or PGD Programming Data a bidirectional synchronous serial data line
24. MICROCHIP PICkit 2 Microcontroller Programmer USERS GUIDE 2007 Microchip Technology Inc DS51553C Note the following details of the code protection feature on Microchip devices Microchip products meet the specification contained in their particular Microchip Data Sheet Microchip believes that its family of products is one of the most secure families of its kind on the market today when used in the intended manner and under normal conditions There are dishonest and possibly illegal methods used to breach the code protection feature All of these methods to our knowledge require using the Microchip products in a manner outside the operating specifications contained in Microchip s Data Sheets Most likely the person doing so is engaged in theft of intellectual property Microchip is willing to work with the customer who is concerned about the integrity of their code Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code Code protection does not mean that we are guaranteeing the product as unbreakable Code protection is constantly evolving We at Microchip are committed to continuously improving the code protection features of our products Attempts to break Microchip s code protection feature may be a violation of the Digital Millennium Copyright Act If such acts allow unauthorized access to your software or other copyrighted work you may have a right to sue for r
25. R USER S GUIDE Table of Contents Pref C RP EE RE canada AAPA I AKERWA 1 Chapter 1 PICkit 2 Programmer Overview i WAO SR a staves us de E mnt eee ee een tee 7 12 HoN giS eri AA a Ra 7 1 3 PICkit 2 Microcontroller Programmer Contents wwwwwwmmmamimammmwa 7 1 4 Introducing the PICkit 2 Microcontroller Programmer 7 1 5 PICkit 2 Microcontroller Programmer Overview s ssssssssssseeessererssrrrsssrrrrees 8 1 5 1 USB Port Connection iii 8 1 9 2 Status LEDS 55888 an fra Mann tn At te Ne ni nt etes 8 Too ENT EE 8 1 5 4 Programming Connector u airnean aa aaa anaa a aai aa iag 9 1 5 5 Lanyard Connection si 9 1 6 Programming Software ee ENER SEENEN EEN 10 1 6 1 Menu Dateie EER RE EES YAA 11 1 6 2 Device Configuration ss 12 1 6 3 Status Window Bar ss 12 1 6 4 Progress Bar ege eege NEEN 12 1 6 5 Device VOD euer Rene Ee ee 12 1 6 6 Memory Zagreb hie mnt etic EE 13 1 6 7 Program Memory wA WA ae 13 1 6 8 Data EEPROM Memory ii 13 Chapter 2 Getting Started ZA e ee le e EE 15 2 2 Installing the PICkit 2 Programming Software 15 2 3 Using the PICkit 2 Programming Software cccceceeeeseeeeeeeeeeeeeeesneeees 15 2 3 1 Connecting to the Device w wwwmwammmamwmaamwawamanamu mwi waemw wima 16 2 3 2 Device Identification ai 16 2 9 3 larget POWEN TEE 17 2 34 MEO RHEA File TE 18 2 979 WATS eg eege eebe ege Ee he d
26. ROCONTROLLER PROGRAMMER OVERVIEW The PICkit 2 Microcontroller Programmer overview is shown in Figure 1 1 FIGURE 1 1 PICkit 2 MICROCONTROLLER PROGRAMMER Legend 1 Status LEDs 3 Lanyard Connection 5 Pin 1 Marker 2 Push Button 4 USB Port Connection 6 Programming Connector 1 5 1 USB Port Connection The USB Port Connection is a USB mini B connector Connect the PICkit 2 Microcontroller Programmer to the PC using the supplied USB cable 1 5 2 Status LEDs The Status LEDs indicate the status of the PICkit 2 Microcontroller Programmer 1 Power green Power is applied to the PICkit 2 Microcontroller Programmer via the USB port 2 Target yellow The PICkit 2 Microcontroller Programmer is powering the target device 3 Busy red The PICkit 2 Microcontroller Programmer is busy with a function such as Program mode or is alerting that a function is in progress 1 5 3 Push Button The push button may be used to initiate the Write Device programming function when Programmer gt Write on PICkit Button is checked K Ee i EEN DS51553C page 8 2007 Microchip Technology Inc PICkit 2 Programmer Overview 1 5 4 Programming Connector The programming connector is a 6 pin header 0 100 spacing that connects to the target device See the pinout specification in Figure 1 2 For more information on how to use the PICkit 2 Microcontroller Programmer with In Circ
27. ammer Overview Provides an overview of the PICkit 2 Microcontroller Programmer Chapter 2 Getting Started Provides Instructions on how to get started using the PICkit 2 Microcontroller Programmer to program Flash based PIC Microcontroller Units MCUs Chapter 3 PICkit 2 Programmer and ICSP Describes programming with the PICkit 2 Microcontroller Programmer using In Circuit Serial Program ming ICSP Chapter 4 PICkit 2 Debug Express Provides a tutorial on using the PICkit 2 Debug Express debugger program Chapter 5 Troubleshooting Provides information on solving common problems Chapter 6 Updating the PICkit 2 Programmer Operating System Provides instruction on how to update your PICkit 2 Microcontroller Program mer s Operating System Appendix A Hardware Schematics Illustrates the PICkit 2 Microcontroller Programmer hardware schematic diagrams DS51553C page 2 2007 Microchip Technology Inc CONVENTIONS USED IN THIS GUIDE Preface This manual uses the following documentation conventions DOCUMENTATION CONVENTIONS Description Represents Examples Arial font Italic characters Referenced books MPLAB IDE User s Guide Emphasized text is the only compiler Initial caps A window the Output window A dialog the Settings dialog A menu selection select Enable Prog
28. anager and general editing and debugging features Programmers The latest information on Microchip programmers These include the MPLAB PM3 and PRO MATE II device programmers and the PICSTART Plus and PICkit development programmers 2007 Microchip Technology Inc DS51553C page 5 PICkit 2 MCU Programmer User s Guide CUSTOMER SUPPORT Users of Microchip products can receive assistance through several channels e Distributor or Representative e Local Sales Office e Field Application Engineer FAE e Technical Support Customers should contact their distributor representative or field application engineer FAE for support Local sales offices are also available to help customers A listing of sales offices and locations is included in the back of this document Technical support is available through the web site at http support microchip com DOCUMENT REVISION HISTORY Revision A July 2005 e Initial release of this document Revision B August 2006 e Updated Preface added Chapter 4 PICkit 2 Debug Express tutorial Revision C January 2007 e Updated Chapters 1 6 e Updated Preface by removing Development Systems Information Line from Customer Support bulleted list SE DS51553C page 6 2007 Microchip Technology Inc MICROCHIP PiCkit 2 MCU PROGRAMMER USER S GUIDE Chapter 1 PICkit 2 Programmer Overview 1 1 INTRODUCTION This chapter introduces the PICkit 2 Microc
29. be presented Select the device family of interest for more information on reserved device resources The following documentation may also be referenced MPLAB ICD 2 In Circuit Debugger User s Guide DS51331 4 2 PICkit 2 DEBUG EXPRESS This section explains how to debug programs using the PICkit 2 Debug Express It is intended for those new to debugging programs but familiar with the MPLAB IDE software For more information on how to use the MPLAB IDE software reference the following documentation MPLAB IDE User s Guide DS51519 MPLAB IDE Quick Start Guide DS51281 MPLAB IDE On line Help 4 2 1 Selecting the Device and Development Mode From the MPLAB IDE menu bar select the PIC MCU device for this tutorial 1 Select Configure gt Select Device FIGURE 4 1 MPLAB IDE MENU BAR 4 MPLAB IDE v7 50 D H inalsA E Configuration Bits ID Memory Settings 2 Click on the Device drop down list and select the PIC16F887 device No other changes needto be made in this dialog bor 3 Click OK DS DS51553C page 30 2007 Microchip Technology Inc PICkit 2 Debug Express FIGURE 4 2 SELECT DEVICE Select Device Device Device Family PIC16F887 ALL bol Support LAB ICD 2 PICkit2 kit 1 LAB REAL ICE MPILER vol LAB ICD 2 PICkit 2 MPLAB ICE 4000 No Module KI Cas 4 2 2 PICkit 2 Microcontr
30. crochip Technology Inc
31. d buttons are clicked the Program Memory window comes up with all zeros What is wrong Answer The device may be code protected Ensure code protection has not been selected in the Configuration Word 2007 Microchip Technology Inc DS51553C page 47 PICkit 2 MCU Programmer User s Guide Microsoft Windows 95 98 NT Question Can run on Windows 95 98 NT Answer No These operating systems either do not support USB or have drivers that are not compatible VDD VPP Errors Question Why do keep getting a VDD Error or VPP Error Answer This error indicates that the PICkit 2 Programmer is not able to drive VDD or VPP to the intended voltage Check the circuit board for shorts for large current draw and verify that the target MCU is connected to the PICkit 2 Programmer in accordance with Chapter 3 PICkit 2 Programmer and ICSP Make sure that VDD capaci tance is not reducing the VDD rise time longer than 500 us Programming Errors Question Why am able to program some parts but not others Answer If some parts are configured for Low Voltage Programming a floating PGM pin can interfere with programming Use a resistor to pull this pin low when programming Some Mid Range parts such as the PIC16F 72 73 74 76 77 family and PIC16F737 747 767 777 family require a minimum programming VDD of 4 75V Depending on the USB voltage the PICkit 2 Microcontroller Programmer may
32. e VDD Power Supply positive voltage e Vss Power Supply ground reference However the application circuit must be designed to allow all the programming signals to be connected to the PIC microcontroller device without distorting the programming signals Figure 3 1 shows a typical circuit as a starting point when designing an application circuit for ICSP For successful ICSP programming the precautions in the following sections need to be followed Note For details on how a specific device is programmed refer to the device programming specification available from the Microchip web site at www microchip com FIGURE 3 1 TYPICAL ICSP APPLICATION CIRCUIT Isolation Circuitry Ge Resistor or Schottky type diode PICKit 2 Programming 5V Header 1 vep MCLR 5 4 VDD gt Vss ICSPDAT PGD ICSPCLK PGC y au AUX v 10k 470 Ohm 7 PWV LM VDD Vsse4 OR 2 RA5 RAO ICSPDAT AAA To Application SE SRA4 RATICSPCLKE taw Circuit 4 RA3 MCLR VPP ORA Toiup Target Microcontroller Device Typical Values 2007 Microchip Technology Inc DS51553C page 25 PICkit 2 MCU Programmer User s Guide 3 2 ISOLATE VPP MCLR PORT PIN When VPP voltage is applied the application circuit needs to take into consideration that the typical VPP voltage is 12V This may be an issue in the following situations
33. e name If read from a device it will display the part name None Empty Erased indicates the buffers are empty and it will display Edited once Program Memory or Data EEPROM Memory has been edited in the window 1 6 7 Program Memory Program code can be loaded into the PICkit 2 Programming Software from File gt Import HEX or it can be read from the device by clicking on the Read button The origin of the code is displayed in the Source block The Program Memory window displays the program code in hexadecimal The code may be edited in the window The check box next to the Program Memory window is only available on devices with EEPROM data memory If the box is checked then Program Memory User IDs and Configuration Words are written to read from and verified on the device If the box is unchecked then Program Memory User IDs and Configuration Words will not be erased or altered during a Write Device Operation and will not be read or verified The checkbox does not affect Erase Device or Blank Check operations Both memory window checkboxes may not be cleared at the same time 1 6 8 Data EEPROM Memory Similar to Program Memory above program code can be loaded into the PICkit 2 Programming Software from File gt Import HEX or it can be read from the device by clicking on the Read button The origin of the code is displayed in the Source block The Data EEPROM Memory window displays the program code in hexadecimal The code may
34. e progress of an operation 1 6 5 Device VDD The PICkit 2 Programmer VDD may be turned on and off by clicking the checkbox On The voltage may be set in the box on the right either by typing it directly or using the up down arrows to adjust it a tenth of a volt at a time The maximum and minimum allowed voltages will vary depending on the target device DS51553C page 12 2007 Microchip Technology Inc PICkit 2 Programmer Overview If the On checkbox is clear PICkit 2 Programmer will automatically turn on the VDD at the set voltage during any requested programming operation FIGURE 1 4 PICKIT 2 MICROCONTROLLER PROGRAMMER SUPPLIED VDD VDD PICKi 2 On 5 0 7 MCLR If the target device has its own power supply then PICkit 2 Programmer will display the detected VDD voltage in the box on the right which will be grayed out to prevent being changed The checkbox text changes to check and clicking on the checkbox will update the detected VDD voltage value If Target VDD gt Auto Detect is selected clicking on the checkbox will revert the VDD mode back to PICkit 2 Programmer supplied VDD if a target power supply is no longer detected FIGURE 1 5 TARGET SUPPLIED Vop VDD Target Check MCLR 1 6 6 Memory Source The Source bar displays the source of the currently loaded device data If read from a hex file it will display the hex fil
35. ectory 4 1 2 Resources Used by PICkit 2 Debug Express Due to the built in in circuit debugging capability of ICD devices and the ICSP function offered by the debugger the PICkit 2 Debug Express uses some on chip resources when debugging General Resources for Mid Range Devices e MCLR pin reserved for debugging this pin cannot be used as digital I O while debugging MCLR VPP shared for programming The ICSPDAT and ICSPCLK port pins are reserved for programming and in circuit debugging Therefore other functions multiplexed on these pins will not be available during debug One stack level not available Program and Data Memory Resources The PICkit 2 Debug Express uses program memory and file register locations in the target device during debugging These locations are not available for use by user code In the MPLAB IDE registers marked with an R in register displays represent reserved registers 2007 Microchip Technology Inc DS51553C page 29 PICkit 2 MCU Programmer User s Guide For device specific reserved locations see MPLAB IDE help for the MPLAB ICD 2 In the MPLAB IDE select menu Help gt Topics In the Help Topics dialog under Debuggers select MPLAB ICD 2 and click OK In the MPLAB ICD 2 Help dialog select Operation under the Contents tab Select MPLAB ICD 2 Overview then Resources Used By MPLAB ICD 2 A list of device families will
36. elief under that Act Information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates It is your responsibility to ensure that your application meets with your specifications MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED WRITTEN OR ORAL STATUTORY OR OTHERWISE RELATED TO THE INFORMATION INCLUDING BUT NOT LIMITED TO ITS CONDITION QUALITY PERFORMANCE MERCHANTABILITY OR FITNESS FOR PURPOSE Microchip disclaims all liability arising from this information and its use Use of Microchip devices in life support and or safety applications is entirely at the buyer s risk and the buyer agrees to defend indemnify and hold harmless Microchip from any and all damages claims suits or expenses resulting from such use No licenses are conveyed implicitly or otherwise under any Microchip intellectual property rights QUALITY MANAGEMENT SYSTEM CERTIFIED BY DNV ISO TS 16949 2002 Trademarks The Microchip name and logo the Microchip logo Accuron dsPIC KEELOQ microID MPLAB PIC PICmicro PICSTART PRO MATE PowerSmart rfPIC and SmartShunt are registered trademarks of Microchip Technology Incorporated in the U S A and other countries AmpLab FilterLab Migratable Memory MXDEV MXLAB SEEVAL SmartSensor and The Embedded Control Solutions Company are registered trademarks of Microchip Technology
37. er Programmer Debug Tool 31 4 2 3 Updating PICkit 2 Programmer Operating System wwwwwwwwwmwawa 33 4 2 4 Running the Project Wizard 0 eee eeeceeeeee eee ee eee eene cette tases ee eaaeeeeeeeaeeeeenenea 33 4 2 5 PIC16887 Debug Demo Project 0 c ccceceeeeeeeeeeeeeececaeeeeaeeseeeeeesnaeeesenes 36 4 2 6 Creating a Hex File iii 37 4 2 7 Setting Debug Options iii 38 4 2 8 Loading Program Code for Debugging wwwwsmmmamumawmanamuamwmama wawa 39 4 2 9 PIC16F887 Debug Demo cccceeeeeeeneeeeeeeeeeeeeeeaeeeceaaeessaaeeseeneeesaeeeeees 40 4 2 10 Debugging the PIC16F887 Debug Demo Code wwwwawwmammmawwmwwa 41 4 2 11 Programming the Application ec eeeeeeeeeeeeeeeeeeeteeeeeeetaaeeeeetieeeeeneaea 44 Chapter 5 Troubleshooting 5 1 Introd tti n EE 47 5 2 Frequently Asked Questions sistema eege dead ee 47 Chapter 6 Updating the PICkit 2 Programmer Operating System n VA Yo Ya lee EE EE 49 6 2 Updating the PICkit 2 Microcontroller Programmer scceeeeeeeeees 49 Appendix A Hardware Schematics AT Introdu tiO n issus ann ed Rate a 51 Worldwide Sales and Service si sssssnnnnnnensnnnnneeeeennnnnes 54 DS51553C page iv 2007 Microchip Technology Inc MICROCHIP Pickit 2 MCU PROGRAMMER USER S GUIDE Preface NOTICE TO CUSTOMERS All documentation becomes dated and this manual is no exception Microchi
38. es 78 Symbols 4 2 6 Creating a Hex File Select Project gt Build All or right click on the project name in the Project Window and select Build All from the pop up menu The MPASM assembler will create a hex file with the same name as the source asm file FIGURE 4 16 BUILD PROJECT w PIC16F887 Debug Demo MPLAB IDE v7 50 File Edit View ETES Debugger Programmer Tools Configure Window Help Deu Project Wizard e BR ci os 5 New Open Close a pics Set Active Project SE Clean Ch St Build All Ctrl F10 Make F10 Build Options D D DC Save Project Save Project As Add Files to Project Add New File to Project Remove File From Project Select Language Toolsuite 1 Set Language Tool Locations Version Control SR EA 2007 Microchip Technology Inc DS51553C page 37 PICkit 2 MCU Programmer User s Guide FIGURE 4 17 OUTPUT WINDOW Build Version Control Find in Files Clean Deleting intermediary and output files Clean Deleted file C Program Files Microchip PICkit 2 v2 DBE Demo PIC16F88 Debug Demo mcs Clean Done Executing C Program Files Microchip MPASM Suite MPASMWIN EXE q p16F 88 16F88 Demo asn Message 302 C PROGRAM FILES MICROCHIPAPICKIT 2 V2 DBE DEMO 16F887DEMO ASM 59 Regi Message 302 C PROGRAM FILES MICROCHIPAPICKIT 2 VADBE DEMO 6F887DEMO ASM 60 Regi Message 302 C PROGRAM FILES MICROCHIPAPICKIT 2 VADB
39. ess to commonly used debug operations Debugger Menu Toolbar Buttons Run gt Halt n Animate DD Step Into Di Step Over Di Step Out P Reset EL 4 2 9 1 REAL TIME MODE Open the 16F887Demo asn file 1 Double click on the 16F887Demo asm file from the Project Window or select File gt Open from the toolbar menu 2 Select Debugger gt Run or click the Run button 3 Turn the potentiometer RAO located on the demo board and observe the LEDs If the program was working properly the LEDs would rotate faster or slower depending on which direction the potentiometer is turned However a bug has been intentionally placed in the code for debugging demonstration purposes See the next section Section 4 2 10 Debugging the PIC16F887 Debug Demo Code for debugging instructions 4 Select Debugger gt Halt or click the Halt button to stop the program execution 5 Select Debugger gt Reset to reset the program DS51553C page 40 2007 Microchip Technology Inc PICkit 2 Debug Express 4 2 10 Debugging the PIC16F887 Debug Demo Code Any of the following issues can prevent the PIC16F887 Debug Demo program from working properly e The A D converter value is not being written properly to the Delay routine e The A D converter is not enabled or has not been set to convert e A typing error in the source code has caused the program to function improperly To explore the firs
40. for installing the PICkit 2 Programming Software If the introductory screen does not appear browse to the CD ROM directory and select the AutorunPro exe program 2 3 USING THE PICkit 2 PROGRAMMING SOFTWARE Start the PICkit 2 Programming Software by selecting Start gt Programs gt Microchip gt DICK 2 The programming interface appears as shown in Figure 2 1 2007 Microchip Technology Inc DS51553C page 15 PICkit 2 MCU Programmer User s Guide FIGURE 2 1 PICkit 2 PROGRAMMING SOFTWARE gt PICkit 2 Programmer File Device Family Programmer Tools Help Midrange Configuration Device PIC16F887 Configuration 3FFF 0700 User IDs FF FF FF FF Checksum 26FF PICkit 2 found and connected K PIC Device Found A MICROCHIP VDD PICkit 2 On a Read Write Verify Erase Blank Check 4MCLR 5 0 Program Memory v Enabled Hex Only Source None Empty Erased 0000 3FFF 3FFF 3FFF 3FFF 3FFF 0008 3FFF 3FFF 3FFF 3FFF 3FFF 0010 3FFF 3FFF 3FFF 3FFF 3FFF 0018 3FFF 3FFF 3FFF 3FFF 3FFF 0020 3FFF 3FFF 3FFF 3FFF 3FFF 0028 3FFF 3FFF 3FFF 3FFF 3FFF 0030 3FFF 3FFF 3FFF 3FFF 3FFF 0038 3FFF 3FFF 3FFF 3FFF 3FFF 0040 3FFF 3FFF 3FFF 3FFF 3FFF 0048 3FFF 3FFF 3FFF 3FFF 3FFF 0050 3FFF 3FFF 3FFF 3FFF 3FFF 0058 3FFF 3FFF 3FFF 3FFF 3FFF EEPROM Data Import Hex File v Enabled Hex Only Write Device FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F
41. h cannot be auto detected such as Baseline will bring up a drop down box from which supported devices may be selected PROGRAMMER e Read Device Reads program memory data EEPROM memory ID locations and Configuration bits Write Device Writes program memory data EEPROM memory ID locations and Configuration bits Verify Verifies program memory data EEPROM memory ID locations and Configuration bits read from the target MCU against the code stored in the programming software Erase Performs a bulk erase of the target MCU OSCCAL and band gap values are preserved on parts with these features Blank Check Performs a blank check of program memory data EEPROM memory ID locations and Configuration bits Verify on Write When checked the device will be immediately verified after programming on a Write recommended When unchecked the device will be programmed but not verified on a Write Hold Device in Reset When checked the MCLR VPP pin is held low asserted When unchecked the pin is released tri stated allowing an external pull up to bring the device out of Reset Write on PICkit Button When checked a Write operation will be initiated by pressing the PICkit 2 button TOOLS e Enable Code Protect Enables code protection features of the microcontroller on future Write operations e Enable Data Protect Enables data protection feature of microcontrollers with data EEPROM memory on futu
42. it 2 Microcontroller Programmer uses the bulk erase method that requires a minimum VDD The user will be warned if VDD is below the minimum for the connected device 2 3 11 Blank Check The Blank Check function will read the entire device to determine if Program Memory EEPROM Data memory User IDs and Configuration bits are erased All memory regions will be examined regardless of the state of the Program Memory and EEPROM Data Enabled checkboxes 2 3 12 Auto Import Hex Write Device Button This features allows PICkit 2 Programmer to automatically import a hex file and write it to a connected device when the hex file is updated for example on a new firmware build To use this feature click on the Auto Import Hex Write Device button shown in Figure 2 12 This will bring up an Import Hex file dialog defaulting to the first hex file in the file history under the File menu After selecting a file it will be written to the device The PICkit 2 Microcontroller Programmer will now monitor the selected hex file for updates When the file has been updated has a newer time stamp the PICkit 2 Microcontroller Programmer will automatically re import the hex file and write to the target device While this feature is enabled other programming operations are disabled The Auto Import Hex Write Device button will remain depressed while this feature is active as shown in Figure 2 13 To stop using this feature click the Auto
43. ite Read Verify Erase Blank Check Checked Checked All Memory Regions All Memory Regions Checked Program Memory All Memory Regions User IDS Configuration Checked EEPROM only All Memory Regions Not Allowed 2 3 6 Automatic File Reload Prior to each write the imported hex file time stamp is compared to the version on the disk If the version on the disk is newer it is reloaded This occurs only when a hex file has been read from the disk This feature ensures that the latest version built by MPLAB IDE will be written to the device 2 3 7 The Verify function verifies the device program to the imported hex file It compares all areas of memory including program memory data EEPROM memory ID and Configuration bits To verify the code import the hex file and click the Verify button If the code is the same the status bar turns green and displays Device Verified If a discrepancy is found the status bar turns red and displays where the error is located Error in Program Memory Data EEPROM Memory or Configuration Bits Table 2 1 illustrates how Verify is affected by the memory region checkboxes Verify 2 3 8 Read To view the code written to the PIC MCU click the Read button The code is displayed in the Program and Data EEPROM Memory windows for your review If all zeros are displayed it is possible that the device is code protected Table 2 1 illustrates how Read is affected by the memory region chec
44. kboxes 2 3 9 Code Protect Device The Code and Data Protect functions enable the read protection features of the Pic MCU To protect the program memory code complete the following steps 1 Import hex file 2 Select Tools gt Enable Code Protect as shown in Figure 2 11 3 Click Write Devices that have EEPROM Data Memory may protect it by selecting Tools gt Enable Data Protect mms 2007 Microchip Technology Inc DS51553C page 21 PICkit 2 MCU Programmer User s Guide FIGURE 2 11 ENABLE CODE PROTECT 5 PICkit 2 Programmer File Device Family Programmer Tools Midrange Configuration Enable Code Protect Device PIC16F887 Enable Data Protect User IDs FF FF FF FF Target YDD Source gt East Programming Hex file sucessfully imported Check Communication Checksum 9187 Troubleshoot Download PICkit 2 Firmware Read Write Verify Note Ifthe device is read after it has been protected the protected memory regions will display all zeros 2 3 10 Erase The Erase function erases the program memory data EEPROM memory ID and Configuration bits regardless of the state of the Program Memory and EEPROM Data Enabled checkboxes However this function is not normally needed since the Write function performs an erase operation prior to programming the PIC MCU To erase the device click the Erase button Note The PICk
45. ke PortD all output SetupAnalogPins banksel 4 address Register Page Z bsf movlr configure Port A pin 0 Analog movwf movlw remaining pins are all digital movwf SetupAzD banksel ADCON1 address Register Page L movlw 0x00 AZD ustified references are ADCONL ADCONO address Register Page 0 ADCONO configure AZD for Fosc 8 Channel 0 InitRegisters banksel Display movilw 0x80 movwf clrf clrf ookingFor Looking for a 0 on the button MainLoop movt isplay w Copy the display to the LEDs movwf 14 Select File gt Save to save the changes 15 Select Project gt Build All to rebuild the project A message will indicate that the program has been rebuilt The PICkit 2 Programmer must be reprogrammed for the changes to take effect 16 Select Debugger gt Program to reprogram the PICkit 2 Programmer with the changes When the PICkit 2 Programmer dialog indicates Programming Succeeded the program is ready to run again 17 Right click on the line of code that previously had the breakpoint and select Remove gt Breakpoint 18 Select Debugger gt Run to run the program in Real Time mode Turn the potentiometer RAO to change the value displayed on the LEDs The source code in this tutorial contained only one bug However real code may have more Using the PICkit 2 Programmer and MPLAB IDE debugging functions users can successfully find and fix problems in their code 4 2 11 P
46. mer will automatically detect an externally powered board The Device VDD will be updated to VDD Target the check box text will change to Check and the detected VDD voltage is displayed in the grayed out voltage box as in Figure 2 7 Clicking the check box will update the detected VDD voltage displayed in the voltage box If no VDD voltage is detected when the check box is clicked then PICkit 2 Programmer will return to supplying VDD power to the target device Note The maximum external VDD that may be used with the PICkit 2 Program mer is 5 0 Volts The minimum external VDD that may be used with the PICkit 2 Programmer is 2 5 Volts FIGURE 2 7 EXTERNALLY POWERED TARGET Midrange device found AN MICROCHIP j VDD Target Read Write Verify Erase Blank Check Check DS51553C page 18 2007 Microchip Technology Inc Getting Started 2 3 4 Import HEX File To import a compiled program hex file select File gt Import HEX as shown in Figure 2 8 Browse for the hex file and click Open The code is displayed in the Program Memory and EE Data Memory windows The name of the hex file is displayed in the Source block The PICkit 2 Microcontroller Programmer will warn the user if the hex file does not contain any Configuration Words The user can be sure these are included in the hex file by selecting File gt Export and saving the hex file in MPLAB IDE
47. nication status between the PICkit 2 and Target Board FIGURE 4 6 PICkit 2 MICROCONTROLLER PROGRAMMER CONNECT Build Version Control Find in Files PICKit 2 Initializing PICKit 2 version 0 0 2 9 Found PICkit 2 Operating System Version 2 1 0 Target power not detected Powering from PICkit 2 PIC16F88 found Rev 0x2 PICkit 2 Ready Found PICkit 2 Operating Systern Version 2 1 0 Target power not detected Powering from PICkit 2 PIC16F887 found Rev 0x2 PICkit 2 Ready 4 2 3 Updating PICkit 2 Firmware Operating System Depending on the version of the MPLAB IDE software or the selected device a message may appear indicating that the firmware needs to be updated MPLAB IDE will automatically install new firmware see Figure 4 7 FIGURE 4 7 UPDATING PICkit 2 FIRMWARE DIALOG Build Version Control Find in Files PICKit 2 Initializing PICKit 2 version 0 0 2 9 Found PICKit 2 Epon System version 1 20 0 PKwarn0001 There i t perating Sytem available Downloading PICKit 2 os 2 1 0 4 2 4 Running the Project Wizard For this project the MPASM Assembler tool will be used 1 Select Project gt Project Wizard to setup the first project The Project Wizard Welcome menu will display 2 Click Next to continue to Step One 2007 Microchip Technology Inc DS51553C page 33 PICkit 2 MCU Programmer User s Guide FIGURE 4 8 PROJECT WIZARD P
48. ntroller Programmer will flash When the update completes successfully the status bar will display Operating System Verified and the Busy LED will go out The operating system update is then complete KEE EE EEN 5 DS51553C page 50 2007 Microchip Technology Inc PICkit 2 MCU PROGRAMMER USER S GUIDE PICkit 2 MICROCONTROLLER PROGRAMMER SCHEMATIC DIAGRAM PAGE 1 OF 2 Appendix A Hardware Schematics This appendix contains PICkit 2 Microcontroller Programmer schematic diagrams MICROCHIP INTRODUCTION FIGURE A 1 A 1 l gen Ap gen AS LOL An lt HD 700 LE S 179 v S OSLO 29 HO XL 994 DE ntoosdow YY ah als dA 0 SON Bn 1 WAFOUFOR i ASNA Ld99 Z94 30N 2499 180 L L09 IHOELL OSOIL 094 OOdIEIg ML 90 D 99 18 9284 asn A n WediUgeg 9VH OH19 T9S0 E SN wa CN 191 Pen d RO gt ONNZLNISNV ZEN Die miyo d wee fav 191 00A TS 10SMOS LLNI OLNV LEN yas gt VOS IGS 0114 OLNUZLNV O8Y How Env EA TON A9H 1NOL9 H901 vE A3HN ENV EVE Loge 33YA9 43YA CNY ZWY 83 191 GGA LNY LYN J9v40333 ddA ONV OVY 919 i eeu 151 HON gt LNOZ9 NIGATH SS PNV SVY MOTA aay esa 1aouvi isa asna NYHOOUd IMS OS 0SSZ48 ld in vA OL ZE
49. o the LEDs e3 movwf PORTD B4 nop wait total of SuS for AZD amp to se es nop wait lus 86 nop wait lus e7 nop wait lus ss nop wait lus 89 bet ADCONO GO_DONE start conversion 30 btfsc ADCONO GO_DONE this bit will change to zero when t 91 goto 1 92 movt ADRESH w Copy the AZD result to the delay lo 93 move Delay l 24 95 2DDelayLoop 26 incfsz D Py 97 goto A layLoop 98 incfsz Delay l f 99 goto AZDDelayLoop 100 101 102 moviw 13 Delay another 10m plus whatever wa 103 movwf Delay l 104 TenmSdelay 105 decfsz 106 goto 107 decfsz 108 goto 109 110 btfsc LookingFor 0 111 goto LookingForl a RE Taaalinetayn lt gt 2007 Microchip Technology Inc DS51553C page 43 PICkit 2 MCU Programmer User s Guide 13 Examine the values of the ADCONO and ADCON1 registers in the Watch window The ADCONDO value is 0x40 b 01000000 This corresponds to the hex value designated in the program However this is not correct A review of the PIC 16F882 883 884 886 887 Data Sheet DS41291 Analog to Digital A D Converter Module section indicates that the last bit should be a 1 b 01000001 to turn on the A D module To fix this bug change movlw 0x40 to movlw 0x41 as shown in Figure 4 27 FIGURE 4 27 A D MODULE CODE L C 16F887Demo asm Main SetupPinDirections banksel TRISA select Register Page 1 movlw OxFF movwf TRISA Make PortA all input clrf Ma
50. oller Programmer Debug Tool Select the PICkit 2 Microcontroller Programmer as the debug tool e Select Debugger gt Select Tool gt PICkit 2 The Output window displays communication status between the PICkit 2 Microcontroller Programmer and Target Board as shown in Figure 4 4 FIGURE 4 3 PICkit 2 DEBUG TOOL wm MPLAB IDE v7 50 File Edit View Project ils Programmer Tools Configure Window Help DSL ol la v None Clear Memory gt 1 MPLAB ICD 2 3 MPLAB SIM 2007 Microchip Technology Inc DS51553C page 31 PICkit 2 MCU Programmer User s Guide FIGURE 4 4 OUTPUT WINDOW E Output Build Version Control Find in Files PICKit 2 Initializing PICKit 2 version 0 0 2 9 Found PICkit 2 Operating Systern Version 2 1 0 Target power not detected Powering from PICkit 2 PIC16F88 found Rev 0x2 PICkit 2 Ready 4 Select Debugger gt Settings to setup the PICkit 2 operation 5 Click the Connect on Startup check box to enable the auto connection feature 6 Click Ok FIGURE 4 5 PICkit 2 SETTINGS PICkit 2 Settings Settings Warnings Automatically Program after a successful build Run after a successful program Output to debug file DS51553C page 32 2007 Microchip Technology Inc PICkit 2 Debug Express 7 Select Debugger gt Connect to connect to the PICkit 2 The Output window displays commu
51. ontroller Programmer and describes the PICkit 2 Microcontroller Programmer features and menu functions 1 2 HIGHLIGHTS This chapter discusses e The PICkit 2 Microcontroller Programmer Contents e The PICkit 2 Microcontroller Programmer Overview e PICkit 2 Programming Software 1 3 PICkit 2 MICROCONTROLLER PROGRAMMER CONTENTS The PICkit 2 Microcontroller Programmer Kit contains the following items 1 The PICkit 2 Microcontroller Programmer 2 USB cable 3 PICkit Starter Kit CD ROM 1 4 INTRODUCING THE PICkit 2 MICROCONTROLLER PROGRAMMER The PICkit 2 Microcontroller Programmer is a low cost development programmer It is capable of programming most of Microchip s Flash microcontrollers For specific products supported see the README file included on the PICkit Starter Kit CD ROM The PICkit 2 Microcontroller Programmer Operating System firmware can be easily upgraded from the programming software New device support can be added by updating the operating system The latest firmware is available on Microchip s web site www microchip com Note The PICkit 2 Microcontroller Programmer is intended for development programming For production programming please consider the MPLAB PM3 Programmer or other third party programmers designed for the production environment 2007 Microchip Technology Inc DS51553C page 7 PICkit 2 MCU Programmer User s Guide 1 5 PICkit 2 MIC
52. p tools and documentation are constantly evolving to meet customer needs so some actual dialogs and or tool descriptions may differ from those in this document Please refer to our web site www microchip com to obtain the latest documentation available Documents are identified with a DS number This number is located on the bottom of each page in front of the page number The numbering convention for the DS number is DSXXXXXA where XXXXX is the document number and A is the revision level of the document For the most up to date information on development tools see the MPLAB IDE on line help Select the Help menu and then Topics to open a list of available on line help files INTRODUCTION This chapter contains general information that will be useful to know before using the PICkit 2 Microcontroller Programmer 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 Document Revision History 2007 Microchip Technology Inc DS51553C page 1 PICkit 2 MCU Programmer User s Guide DOCUMENT LAYOUT This document describes how to use the PICkit 2 Microcontroller Programmer as a development tool to emulate and debug firmware on a target board The manual layout is as follows Chapter 1 PICkit 2 Progr
53. rammer Quotes A field name in a window or __ Save project before build dialog Underlined italic text with A menu path File gt Save right angle bracket Bold characters A dialog button Click OK A tab Click the Power tab N Rnnnn A number in verilog format where Nis the total number of digits R is the radix andnis a digit 4 b0010 2 nF 1 Text in angle brackets lt gt A key on the keyboard Press lt Enter gt lt F1 gt Courier New font Plain Courier New Italic Courier New Sample source code define START Filenames autoexec bat File paths c mcci8 h Keywords _asm _endasm static Command line options Opa Opa Bit values 0 1 Constants OxFF A A variable argument file o where file can be any valid filename Square brackets Optional arguments mcc18 options file options Curly brackets and pipe character Ellipses Choice of mutually exclusive arguments an OR selection Replaces repeated text errorlevel 0 1 var_name Represents code supplied by user var_name void main void 2007 Microchip Technology Inc DS51553C page 3 PICkit 2 MCU Programmer User s Guide WARRANTY REGISTRATION Please complete the enclosed Warranty Registration Card and mail it promptly Sending in the Warranty Registration Card entitles users to receive new product upda
54. re Write operations e Set OSCCAL Allows the OSCCAL value to be changed for devices where it is stored in the last location of Program Memory e Target VDD Source gt Auto Detect PICkit 2 Programmer will automatically detect whether the target device has its own power supply or needs to be powered from by the PICkit 2 Programmer on each operation Force PICkit 2 PICkit 2 Programmer will always attempt to supply VDD to the target device 2007 Microchip Technology Inc DS51553C page 11 PICkit 2 MCU Programmer User s Guide Force Target PICkit 2 Programmer will always assume the target has its own power supply Fast Programming When checked PICkit 2 Programmer will attempt to program the device as fast as possible When unchecked PICkit 2 Programmer will slow down ICSP communication This may be helpful for targets with loaded ICSP lines Check Communication Verifies USB communication with the PICkit 2 Programmer and ICSP communication with a target device by attempting to identify the connected device by its device ID Troubleshooting Opens a wizard to help with troubleshooting connectivity from PICkit 2 Programmer to the target device This is most useful where the PICkit 2 Programmer is unable to detect the target device at all Download PICkit 2 Programmer Operating System Performs a download of the PICkit 2 Microcontroller Programmer operating
55. rogramming the Application When the program is successfully debugged and running the next step is to program the PIC MCU for stand alone operation in the finished design When doing this the resources reserved by the ICD are released for use by the application To program the application use the following steps DS51553C page 44 2007 Microchip Technology Inc PICkit 2 Debug Express 1 Disable PICkit 2 Programmer as a debug tool by selecting Debugger gt Select Tool gt None 2 Select PICkit 2 Programmer as the programmer in Programmer gt Select Tool menu 3 Optional Set up the ID in Configure gt ID Memory FIGURE 4 28 CONFIGURE ID MEMORY v7 50 rer Tools MCE Window Help 2 R Select Device Configuration Bits ID Memory Settings FIGURE 4 29 USER ID MEMORY User ID Memory User ID FF FF FF AF Use Unprotected Checksum OK Cancel Help 4 Setup the parameters for programming on the Programmer gt Settings Program tab 5 Select Programmer gt Program Now the PICkit 2 Programmer can reset and run the target 2007 Microchip Technology Inc DS51553C page 45 PICkit 2 MCU Programmer User s Guide NOTES DS51553C page 46 2007 Microchip Technology Inc MICROCHIP _pickitTM 2 MCU PROGRAMMER USER S GUIDE Chapter 5 Troubleshooting 5 1 INTRODUCTION This chapter describes questions and an
56. roject Wizard Ly Welcome Wi This wizard helps you create and configure a new MPLAB A project Aa To continue click Next Cancel Help 3 Select the PIC16F887 device from the Device drop down box 4 Click Next to continue to Step Two FIGURE 4 9 STEP ONE Project Wizard Step One Select a device Device PIC16F887 Caa Cee Cons Ce 5 Select Microchip MPASM Toolsuite from the Active Toolsuite drop down menu Make sure the tools are set to the proper executables by default in the C Program Files Microchip MPASM Suite folder as follows e MPASM assembler should be pointing to mpasmwin exe e MPLINK Linker should be pointing to mplink exe e MPLIB Librarian should be pointing to mplib exe 6 Click Next to continue to Step Three DS51553C page 34 2007 Microchip Technology Inc PICkit 2 Debug Express FIGURE 4 10 STEP TWO Project Wizard Step Two Select a language toolsuite Active Toolsuite Microchip MPASM Toolsuite Toolsuite Contents MPASM Assembler mpasmwin exe MPLINK Object Linker mplink exe MPLIB Librarian mplib exe Location C Program Files Microchip MPASM Suite MPASMWIN EXE Help My Suite Isn t Listed Show all installed toolsuites lt Back JI Next gt Cancel IW Help e In Step Three type in the name and location of the project or click the Brow
57. rone A dm D eg dense ere dee had 19 2 3 6 Automatic File Reload wwwwwmmwwananamwananawumanaami maanani maanazumaananiwana 20 KE e e EE 20 Kee WEE 21 2 3 9 Code Protect Device issus 21 23 10 Eraso sennie cael NEEN a Ee 21 2 3 11 Blank Ee EE 22 2 3 12 Auto Import Hex Write Device Button 22 2 3 13 Read Device Export Hex File Button 23 2007 Microchip Technology Inc DS51553C page iii PICkit 2 MCU Programmer User s Guide Chapter 3 PICkit 2 Programmer and ICSP SU e ugeet e EE 25 3 2 Isolate VPP MGLR Port PIN sieste eEHENAERRSEENEREE EENS EEd AEN 26 3 2 1 If the VPP pin is used as a MCLR pin wwa 26 3 2 2 If the VPP pin is used as an I O port Pil eect eeeeseeeeeeeeeeeeeeteeeeeteaeeeeeneees 26 3 3 Isolate ICSPCLK or PGC and ICSPDAT or PGD ons 26 E TAYA DI Da WA AA ee Eeer 27 3 4 1 The application circuit is powered by the PICkit 2 Microcontroller Neel ul WEE 27 3 4 2 The application circuit is powered externally 27 3 4 3 Bulk Erase is Used eege ede nel Aides antenne 27 EE EE e 28 3 6 Keren ne A ent 28 Chapter 4 PICkit 2 Debug Express 4 1 niroductiOn au AR A AR AR SR EE eee 29 4 1 1 Supported NR 29 4 1 2 Resources Used by PICkit 2 Debug Express wwwmmmmmmwa 29 4 2 PICkit aere clases Eed 30 4 2 1 Selecting the Device and Development Mode ceceeseeeeeteeesteeeeeees 30 4 2 2 PICkit 2 Microcontroll
58. se button to locate the project files e Click Next to continue to Step Four FIGURE 4 11 STEP THREE Project Wizard Step Three Name your project Project Name PIC16F887 Debug Demo Project Directory C Program Files Microchip PICkit 2 v2 DBE Demo Browse lt Back JI Next gt Cancel Help In Step Four add the project files From the left pane window go to C Program Files Microchip PICkit 2 v2 DBE Demo Select and highlight the 16F887Demo asmfile and click the Add button The file will be placed into the right pane window 7 Click the check box next to the file to copy the file into the project directory 8 Click Next to continue to the Summary window Note Files can be added later if needed 2007 Microchip Technology Inc DS51553C page 35 PICkit 2 MCU Programmer User s Guide FIGURE 4 12 ADD FILES Project Wizard Step Four B Add any existing files to your project e C2 PICKit 2 v2 A 16F887Demo asm C Program Fil amp 1 DBE Demo 16F887Demo asm Low Pin Count User Guide Hat PICkit 2 Readme txt PICkit2 User Guide 51552 PICKit2 ini PICKit2V2 exe PK2DeviceFile da_06 PK2DeviceFile dat lt gt ees Check the box to copy the file ta the 1 Third Party project directory Click the filename to lt edit the name of the local copy If any errors have been made click on the Back button to return to any of the
59. sing PICKitTM 2 Microcontroller Programmer to power the application circuit Ensure that the application circuit does not slow the VDD rise time to longer than 500 us 3 4 2 The application circuit is powered externally The PICkit 2 Microcontroller Programmer may be used with application circuits powered externally between 5 0V and 2 5V 3 4 3 Bulk Erase is used Some PIC MCU devices use a bulk erase function to erase program memory data EEPROM memory ID locations and Configuration bits Typically the bulk erase function requires a supply voltage VDD of 4 5 to 5 5 Volts refer to the device programming specification for device specific requirements This voltage range can be a problem if the application circuit is designed to operate at a different supply voltage range In order to bulk erase the PIC MCU the application circuit needs to take into consideration the bulk erase voltage requirement while protecting any voltage sensitive circuitry a 2007 Microchip Technology Inc DS51553C page 27 PICkit 2 MCU Programmer User s Guide 3 5 Vss The power supply ground reference Vss must be at the same potential as the application circuit 3 6 OTHER CONSIDERATIONS Minimize the distance the ICSP signals must travel by placing the ICSP connector as close to the application circuit PIC MCU as possible Minimize any cable length between the PICkit 2 Microcontroller Programmer and application circuit PIC
60. swers to common problems associated with using the PICkit 2 Microcontroller Programmer and how to resolve them 5 2 FREQUENTLY ASKED QUESTIONS Device is not recognized Question Why am I receiving a No Device Found message Answer Verify that the device is supported and that the target MCU is connected to the PICkit 2 Microcontroller Programmer in accordance with Chapter 3 PICkit 2 Programmer and ICSPTM Verify that PIC18F_J_ PIC24 and dsPIC33 devices have an appropriate capacitance on the VDDCORE VCAP pin in accordance with the device data sheet Current Limit Exceeded Question Why am receiving the error message USB Hub Current Limit Exceeded from the Microsoft Windows program Answer Check the application circuit is not drawing more than about 25 mA from the PICkit 2 Programmer Microsoft Windows Driver Question After plugging the PICkit 2 Microcontroller Programmer into the USB port Windows 98 SE asks for a driver Where is the driver Answer PICkit 2 Microcontroller Programmer uses the drivers included with Windows When Windows 98 SE prompts for a driver select Search for the best driver for your device Then select the check box next to Microsoft Windows Update and click Next Windows will automatically install the appropriate driver Do not use Microchip s ICD 2 USB driver Verify and Read Return all Zeros Question When the Verify or Rea
61. system HELP PICkit 2 User s Guide Attempts to launch the PICkit 2 User s Guide PDF Adobe Reader must be installed 44 Pin Demo Board Guide Attempts to launch the 44 Pin Demo Board User s Guide PDF Adobe Reader must be installed LPC Demo Board Guide Attempts to launch the Low Pin Count Demo Board User s Guide PDF Adobe Reader must be installed PICkit 2 Programmer on the web Opens www microchip com pickit2 in the default web browser Readme Opens the PICkit 2 Readme txt file About Opens a dialog with the PICkit 2 Programming Software version the Device File version and the PICkit 2 Programmer firmware version 1 6 2 Device Configuration The Device Configuration window displays the PIC MCU device User ID Configuration Word and Checksum It also displays OSCCAL and Band Gap for parts with those features For baseline 12 bit core devices the user must select the device from the Device drop down menu All other part family devices will be detected by their device ID and the part name will be displayed on the Device line 1 6 3 Status Window The status window displays text status of the operations in progress If an operation is successful the status window will display green background If an operation fails the status window will display red If an operation alerts a caution the status window will display yellow 1 6 4 Progress Bar The progress bar displays th
62. t listed possible issue set a breakpoint at the line of code that writes the value of the A D result to the high order Delay byte 1 Place the cursor on the following line of code in the 16F887Demo asm file movwf Delay 1 as shown in Figure 4 21 At this breakpoint the program will stop once the A D conversion has completed 2 Right click to display a drop down menu 3 Select Set Breakpoint from the drop down menu The program marks the line with the letter B in a red octagon outline as shown in Figure 4 21 FIGURE 4 21 BREAKPOINT M C 16F887Demo asm movilw 0x00 AZD Left Justified references are movwf ADCONI banksel ADCONO address Register Page 0 movlw 0x40 movwf ADCONO configure AZD for Fosc 8 Channel 0 InitRegisters banksel movlw movwf clrf clrf LookingFor Looking for a 0 on the button MainLoop movt Display w Copy the display to the LEDs movwf PORTD nop nop nop nop ADCONO GO_DONE start ersion ADCONO GO_DONE this bit will change to zero when t 1 ADRESH w Copy the AZD result to the delay lo Waste time 4 Select Debugger gt Run or click the Run button to run the program in Real Time mode A breakpoint stops a program s execution when the program executes the line marked as a breakpoint 5 Mouse over ADRESH in the listing file and it will show the value of the file register see Figure 4 22 2007 Microchip Technology Inc DS51553C page
63. t these pins be used in the application circuit design the circuitry in a manner that does not alter the signal level and slew rates Isolation circuitry will vary according to the application Figure 3 1 shows one possibility by using series resistors to isolate the ICSP signals from the application circuit DS51553C page 26 2007 Microchip Technology Inc PICkit 2 Programmer and ICSPTM 3 4 VDD During ICSP programming the PIC MCU needs to be powered in accordance with the device specification Typically the PIC MCU supply voltage is connected to the application circuit supply voltage The application circuit can be powered by the PICkit 2 Microcontroller Programmer or externally There are a few precautions that need to be observed 3 4 1 The application circuit is powered by the PICkit 2 Microcontroller Programmer The PICkit 2 Microcontroller Programmer supply voltage may set between the maximum and minimum voltages allowed by the device programming specification unless the minimum is below 2 5V Be sure to set the voltage box to the appropriate voltage before programming the device or turning on VDD CAUTION The USB port current limit is set to 100 mA If the target plus PICkit 2 Microcontrol ler Programmer exceeds this current limit the USB port will turn off The target may be powered externally if more power is required Note Current draw should be limited to 25 mA when u
64. te the following steps Step 1 Download the latest PICkit 2 Microcontroller Programmer Operating System from the Microchip web site at www microchip com Step 2 From the menu select Tools gt Download PICKit 2 Operating System as shown in Figure 6 1 FIGURE 6 1 DOWNLOAD PICkit 2 PROGRAMMER OPERATING SYSTEM 5 PICKit 2 Programmer Eile Device Family Programmer Tools Midrange Configuration Enable Code Protect Ctrl P Device PIC16F887 Enable Data Protect Ctrl D User IDs FF FF FF FF Target YDD Source East Programming PICKit 2 found and connected Check Communication PIC Device Found Checksum 26FF Troubleshoot Download PICkit 2 Operating System Read Write Verify Step 3 Browse to the directory where the latest Operating System code was saved as shown in Figure 6 2 2007 Microchip Technology Inc DS51553C page 49 PICkit 2 MCU Programmer User s Guide FIGURE 6 2 OPEN PICkit 2 PROGRAMMER OPERATING SYSTEM Open PICkit 2 Operating System File Look in O PICkit 2 v2 3 Pk2vo20100 hes Desktop My Documents J 3 My Computer K File name PK2V020100 hex My Network Files of type PICkit 2 05 Step 4 Select the PK2 hex file and click on the Open button The progress of the OS update will be displayed in the status bar of the programming software and the Busy LED on the PICkit 2 Microco
65. tes Interim software releases are available at the Microchip web site RECOMMENDED READING This user s guide describes how to use PICkit 2 Microcontroller Programmer Other useful documents are listed below The following Microchip documents are available and recommended as supplemental reference resources 44 Pin Demo Board User s Guide DS41296 Consult this document for instructions on how to use the 44 Pin Demo Board as a development tool to emulate and debug firmware on a target board PICkit 2 Low Pin Count Demo Board User s Guide DS51556 Consult this document for instructions on how to use Microchip Technology s Low Pin Count device 8 pin 14 pin and 20 pin This document includes a series of tutorials MPLAB IDE User s Guide DS51519 Consult this document for more information pertaining to the installation and features of the MPLAB Integrated Development Environment IDE software MPLAB IDE Quick Start Guide DS51281 Describes how to set up the MPLAB IDE software and use it to create projects and program devices MPLAB IDE On line Help In Circuit Serial Programmer ICSP Guide DS30277 This document contains helpful design guidelines for successful ICSP programming It includes application notes on hardware designs and the ICSP programming specifications MPASM Assembler MPLINK Object Linker MPLIB Object Librarian User s Guide DS33014 Describes how to use the Microchip PIC
66. uit Serial Programming ICSP refer to Chapter 3 PICkit 2 Programmer and ICSPTM FIGURE 1 2 PICkit 2 PROGRAMMER CONNECTOR PINOUT Pin 1 Indicator Pin Description 1 VpP MCLR 2 VDD Target Vss ground 4 ICSPDAT PGD 5 ICSPCLK PGC 6 Auxiliary gt O O1 PO es Il Note The 6 pin header 0 100 spacing accepts 0 025 square pins 1 5 5 Lanyard Connection To help prevent possible loss of the The PICkit 2 Microcontroller Programmer a convenient lanyard connection is available on the programmer 2007 Microchip Technology Inc DS51553C page 9 PICkit 2 MCU Programmer User s Guide 1 6 PROGRAMMING SOFTWARE Start the PICkit 2 Programming Software by selecting Start gt Programs gt Microchip gt DICK 2 The programming interface appears as shown in Figure 1 3 For more information on how to us the PICkit 2 Programming Software see Chapter 2 Getting Started Figure 1 3 PICkit 2 Programming Software PICkit 2 Programmer File Device Family Programmer Tools Help ZC Menu Bar Midrange Configuration Device PIC16F887 Configuration 3FFF 0700 Device Configuration User IDs FRERERER Checksum 26FF Status Window HCH 2 found and connected CA PIC Device Found N ICROCHIP WDD PICKit2 Progress Bar Read Write Verify Erase Blank Check SS 6 0 Device VDD Program Memory
67. wt Delay l 104 TenmSdelay 105 decfsz 106 goto 107 decfsz 108 goto 103 110 btfsc LookingFor 0 111 goto LookingForl a dE Lant v lt gt 8 9 Select Debugger gt Resetto reset the program The first instruction should be indicated by a green arrow Select View gt Watch to open a new Watch window This window allows the user to watch the A D register value change as the program executes The Watch dialog opens with the Watch_1 tab selected as shown in Figure 4 24 DS51553C page 42 2007 Microchip Technology Inc PICkit 2 Debug Express FIGURE 4 24 WATCH WINDOW Add SFR ADCONO Add Symbol __16F887 vi Watch Watch 2 Watch 3 Watch 4 10 Select ADCONO and click on the Add SFR button to add ADCOND to the Watch window 11 Repeat Step 10 to add ADCON1 and ADRESH to the Watch window The selected SFRs should be visible in the Watch window as shown in Figure 4 25 FIGURE 4 25 ADD SFR Add SFR ADRESH Add Sumbol 16F887 ADCONO ADCON1 0x00 ADRESH 0x01 Watch Watch 2 Watch 3 watch 4 12 Select Debugger gt Runto the run the program in Real Time mode This time the program will stop after it executes the breakpoint line of code and the instruction after the breakpoint will be indicated as shown in Figure 4 26 FIGURE 4 26 PROGRAM HALTED AFTER BREAK M C 16F887Demo asm 81 MainLoop ez movf Display w Copy the display t

Download Pdf Manuals

image

Related Search

Related Contents

  MC 50 MIC 34C  歯科医療における感染管理のための CDCガイドライン  JL Audio Fathom f212 User's Manual  PM-3310 Clip-on CT Smart Power Meter User`s Manual    Add-On Computer Peripherals (ACP) 1000Base-TX(RJ45) to 1000Base-XU(ST), 1310/1550nm  CATIA-Hilfe \estug - hsw  Descarga aquí  Franke FAK 607 XS  

Copyright © All rights reserved.
Failed to retrieve file