Home
PICkitTM 2 Microcontroller Programmer USER'S GUIDE
Contents
1. 14 2 3 2 Device Identification sise 14 2 9 9 Target FONET iei AA ei it ERO 15 2 3 4 Import HEX File cecinere dee c e ene ees 15 2 9 9 WING asua Chua tee are teet e coto ese etia anc 16 2 3 6 Automatic File Reload EE 17 2 9 aisi nie pH E EE AB IIR EH DER 17 2 358 REAN MED 17 2 3 9 Code Protect Device 2 17 2 9 1 Erase u anh 18 Chapter 3 PICkit 2 and ICSP 3 1 Introduetiori 19 3 2 Isolate VPP MCLR Port Pin inner autrement 20 3 2 1 If the VPP pin is used as MCLR pin 20 3 2 2 If the VPP pin is used as an I O port pin 22 20 3 3 Isolate ICSPCLK or PGC and ICSPDAT or PGD pins 20 3 4 daska astana Maden 21 2006 Microchip Technology Inc DS51553B page iii PICkit 2 User s Guide 3 4 1 The application circuit is powered by the PICkit 2 Microcontroller PIOGgFamlTigrc Su u e dane ze mn tete 21 3 4 2 The application circuit is powered externally 21 3 4 3 Bulk Erase is used cscs cen tected nee ea KHA awa ceeds 21 MSS tetas p AO AR GE TRAE RARE ERA BEN RE GENERE MAR DE SEA ER M X Ner ARE ERR 22 3 5 Other Considerati hS o ite bdo Supe e
2. 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 and ICSP TM For information on how to update the PICkit 2 firmware operating system refer to Chapter 5 Updating the PICkit 2 Operating System 2 2 INSTALLING THE PICkit 2 PROGRAMMING SOFTWARE Insert the PICkit 2 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 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 23 USING THE PICkit 2 PROGRAMMING SOFTWARE Start the PICkit 2 Programming Software by selecting Start gt Programs gt PICkit 2 Microcontroller Programmer gt 2 The programming interface appears as shown in Figure 2 1 FIGURE 2 1 PICkit 2 PROGRAMMING SOFTWARE PICkit 2 Microcontroller Programmer loj xj File Device Family Programmer Tools About Midrange Device Configuration Device PIC16F690 UserlD s Ox F7F7F7F CheckSum OxFFFF Configuration Word Ox3FFF PICKit 2 Firmware Version 1 00 00 Read Write Verify Erase Quit Target Power Program memory Source None empty erased 3FFF 3FFF 0008 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0010
3. U U J J 47 DS51553B page iv 2006 Microchip Technology Inc MICROCHIP PICkit 2 USER S GUIDE Preface NOTICE TO CUSTOMERS documentation becomes dated and this manual is no exception Microchip tools and documentation are constantly evolving to meet customer needs so some actual dialogs and or tool descriptions may differ from those in this document Please refer to our web site www microchip com to obtain the latest documentation available Documents are identified with a DS number This number is located on the bottom of each page in front of the page number The numbering convention for the DS number is DSXXXXXA where XXXXX is the document number and 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 2006 Microchip Technology Inc DS51553B page 1 PICkit 2 Use
4. MICROCHIP PICkit 2 Microcontroller Programmer USER S GUIDE 2006 Microchip Technology Inc r DS51553B Note the following details of the code protection feature 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 wor
5. hex file with the same name as the source asm file FIGURE 4 16 BUILD PROJECT 16 917 Debug Demo MPLAB IDE v7 4 File Edit View Project Debugger Programmer Tools Configure W DG LE Project Wizard Files 7 Select Language Toolsuite Set Language Tool Locations Version Control New Open Close LI PIC16F SetActive Project EE Sou Guickbuild no asm file C3 Clean C Libr F10 Link Build Options B Save Project oth Save Project Add Files to Project Add New File to Project 4 Remove File From Project FIGUR E 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 PIC16F91 Debug Demo mcs Clean Done Executing C Program Files Microchip MPASM Suite MPAsmWin exe q p16F917 PIC16F317 Debuc Message 302 C PROGRAM FILES MICROCHIP PICKIT 2 917 DEBUG DEMO ASM 53 Regist Message 302 C PROGRAM FILES MICROCHIP PICKIT 2 PIC16F91 DEBUG DEMO ASM 54 Registi Message 302 C PROGRAM FILES MICROCHIP PICKIT 2 PIC16F917 DEBUG DEMO ASM 56 Registi Message 302 C PROGRAM FILES MICROCHIP PICKIT APIC16F917 DEBUG DEMO ASM B1 Registi Executing C Program Files Microchip MPASM Suite MPLink exe C Program Files Mi
6. NW 1709591 H 089 3 o T D 50 d mo di Vo 2 Bent LO 799 PIP 8 OM 0L 4 O 0028 De d uo suun OLY va P 8 N uo swn uBiH LOL A azo 906 LAN aa co t b vla S ore d 0001SOHZ ogy 199591 Bee 501 T gt Sit NISL GGA p or N LO UM OL sn OM Ly OT aT 3 ro 904 zio Jr or 9 fa MW xnv EE ME lt 84 191 VEE LOL A PICkit 2 User s Guide 2006 Microchip Technology Inc DS51553B page 46 PICkit 2 User s Guide NOTES 2006 Microchip Technology Inc DS51553B page 47 MICROCHIP WORLDWIDE SALES AND SERVICE AMERICAS Corporate Office 2355 West Chandler Blvd Chandler AZ 85224 6199 Tel 480 792 7200 Fax 480 792 7277 Technical Support http support microchip com Web Address www microchip com Atlanta Alpharetta GA Tel 770 640 0034 Fax 770 640 0307 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 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
7. 3008 0042 2006 Microchip Technology Inc DS51553B page 15 PICkit 2 User s Guide 2 3 5 Write After a device family has been selected and a hex file has been imported the target MCU can be programmed by clicking on the Write button The 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 Note The device will be erased prior to programming The PICkit 2 Microcontroller Programmer uses the bulk erase method that requires VDD voltage between 4 5 to 5 5V If the write is successful the status bar turns green and displays Write Successful as shown in Figure 2 7 FIGURE 2 7 WRITE SUCCESSFUL STATUS PICkit 2 Microcontroller Programmer File Device Family Programmer 15 xl Tools About r Midrange Device Configuration Device PIC16F630 UserlD s Ox7F7F7F7F CheckSum 0 950 Configuration Word Ox30D 4 BandGap Read 0000 0008 1 Verify Erase Quit Program memory Source Reversible LEDs HEX 1683 30FF 0085 0187 3010 009 1283 1703 30F7 009E 1283 1303 3001 009F 3008 0042 Target Power If the write fails the status bar turns red and displays Verify failed as shown in Figure 2 8 This error indicates that the data was corrupted during the programming sequence
8. 8sn Ac 22 S9Vu OXT9 c9SO T A gz WOd Hensay e gg Oli VIVE I l N 191 yz 0 DITO LOSO 5 1 NO 221 HN OZ d zz 195 221 IOSPOS LINIOLNV L EH zo rz VGS IGS 0114 01NUZLNV 08 i eeu 191 j Eu xnv lt AOUInOLO DIDOLPVH priodsol g d3HAIENV EVM m 1ivadsol 9 83 191 ddA ONV OVY mona he wasoud zsa yamod esa 4 i3ouvi 15 Asng IMS 0510992181014 2 HoN in 5 T aie 00 00 masof iy Vo LH cu FASI _ 3 L asn AS gsn AS gsn AS DS51553B page 45 2006 Microchip Technology Inc PICkit 2 MICROCONTROLLER PROGRAMMER 5 DIAGRAM PAGE 2 OF 2 FIGURE A 2 POGELANN N 80 AW LOL HIOW OM 0L 62H O00 y06 18WNW N 92H 1D wN OM 0L 128 OM 0L 5 al A sz vod _ddA T 7 19L 00A fz QNO fe 906 LANW _ ivadsot 5 90 4 T TE H10dS91 5 OM 001 ASZ ONLY F06 18WN N 5 s dnd ES _ OM 0L FAS er 4 4 4 906 so 512
9. IDE User s Guide Emphasized text is the only compiler Initial caps A window the Output window A dialog the Settings dialog A menu selection select Enable Programmer Quotes A field name in a window Save project before build dialog Underlined italic text with A menu path File gt Save right angle bracket Bold characters dialog button Click OK A tab Click the Power tab N Rnnnn A number in verilog format 4 b0010 2 hF1 where N is the total number of digits R is the radix and n is a digit Text in angle brackets lt gt A key on the keyboard Press Enter F1 Courier New font Plain 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 Italic Courier New A variable argument file o Where file can be any valid filename Square brackets Optional arguments mcci8 options file options Curly brackets and pipe Choice of mutually exclusive exrorlevel 0 1 character 1 arguments selection Ellipses Replaces repeated text var_name var name Represents code supplied by void main void user 2006 Technology Inc DS51553B page 3 PICkit 2 User s Guide WARRANTY REGISTRATION Please complete the enclosed Warranty Registration Card and mail it promptly Sending in the Warranty Re
10. If this error is displayed try writing the program to the device again If the error continues see Chapter 6 Troubleshooting for assistance FIGURE 2 8 File Device Family Programmer PICkit 2 Microcontroller Programmer Tools About WRITE ERROR STATUS Midrange Device Configuration Device 0 User ID s Ox F7F7F7F CheckSum 0 950 Configuration Word 0x30D4 Read 0000 0008 1 Verify Erase Quit Program memory Source Reversible LEDs HEX 1683 30FF 0085 0187 3010 009 1283 1703 30F7 009E 1283 1303 3001 009F 3008 0042 Target Power DS51553B page 16 2006 Microchip Technology Inc Getting Started 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 Verify 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 Configu ration 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 discrepancy is found the status bar turns
11. check the Target Power check box as shown in Figure 2 5 Note When starting the PICkit 2 Microcontroller Program target power defaults to off CAUTION The USB port current limit is set to 100 mA If the target plus PICkit 2 Microcontroller 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 PICkit 2 Microcontroller Programmer ioj xj File Device Family Programmer Tools About Midrange Device Configuration Device PIC16F690 Configuration Word Ox3FFF User ID s Ox F7F AF 7F ee CheckSum OxFFFF axe Read Write Verify Erase Quit Target Power 2 3 4 Import HEX File To import a compiled program file select File gt Import HEX as shown Figure 2 6 Browse for the hex file and click Open The code is displayed in the Program Memory and EE Data Memory windows The name ofthe hex file is displayed in the Source block FIGURE 2 6 IMPORT HEX FILE PICkit 2 Microcontroller Programmer mj xj File Device Family Programmer Tools About Import File Ctrl I ration Export File Ctrl E Configuration Word Ox3ED4 JSU L Ctri Q TE imported Read Write Verify Erase Quit Target Power Program memory Source Reversible LEDs HEX 0000 1683 30FF 0085 0187 3010 009 1283 1703 0008 30F 009E 1283 1303 3001 009
12. 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0018 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0020 3FFF 3FFF 3FFF 3FFF 3FFF 0028 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0030 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0038 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0040 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0048 3FFF 3FFF 3FFF 3FFF 3FFF JEFF 0050 3FFF 3FFF JEFE 3FFF 3FFF JEFF 0058 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0060 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0068 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF IEEE VEEL ICCC IDCC 2LLL ICOC ICCC Vere F MICROCHIP 2006 Microchip Technology Inc DS51553B page 13 PICkit 2 User s Guide 2 3 1 Selecting the Device Family The PICkit 2 Microcontroller Programmer is capable of programming a variety of Flash based Microchip PICmicro microcontrollers The first step in using the PICkit 2 Microcontroller Programmer is to 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 Microcontroller Programmer File Device Family Programmer Tools About Mi Baseline 12 bit core De v Midrange 14 bit Core Configuration Word Ox3FFF 2 3 2 Device Identification If the Mid range 14 bit core Flash device family is selected the PICkit 2 Microc
13. program executes The Watch dialog opens with the Watch_1 tab selected as shown in Figure 4 24 c Y Irr r rs I nc r m rr r DS51553B page 36 2006 Microchip Technology Inc PICkit 2 Debug Express FIGURE 4 24 WATCH WINDOW Watch Add SFR ADCONO Add Symbol Delay address Symbol Name Value Watch Watch2 Watch 3 Watch 4 10 Select ADCONO and click on the Add SFR button to add ADCONO 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 JADRESH z Add Symbol Delay address Symbol Name value ADCONO ADCON1 ADRESH Watch Watch2 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 Bl C PIC16F917 Debug Demo asm movwf PORTD nop wait SuS for AZD amp to settle an nop wait lus nop wait lus nop wait lus nop wait lu bsf ADCONO GO DONE start conversion btfsc ADCONO GO0 DONE this bit will change to zero when goto 1 movf ADRESH w Copy the AZD result to the delay movwf
14. red and displays where the error is located Error in Program Memory Data EEPROM Memory or Configuration Bits 2 3 8 Read To view the code written to the PICmicro 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 2 3 9 Code Protect Device The Code Protect Device function enables the code protection features of the PICmicro MCU To protect the code complete the following steps 1 Import hex file 2 Select Tools Code Protect Device as shown in Figure 2 9 3 Click Write FIGURE 2 9 ENABLE CODE PROTECT PICkit 2 Microcontroller Programmer x File Device Family Programmer Tools About Midrange Device Configuration BR Device Not Present Device Power User ID s Ox F7F7F7F CheckSum 0xC950 Download PICkit 2 Operating System File successfully imported Note Ifthe device is read after it has been code protected Program Memory Data EEPROM Memory windows will display all zeros 2006 Microchip Technology Inc DS51553B page 17 PICkit 2 User s Guide 2 3 10 Erase The Erase function erases the program memory data EEPROM memory ID and Configuration bits However this function is not normally needed since the Write function performs an erase operation prior to programming the MCU To e
15. used for quick access to commonly used debug operations Debugger Menu Toolbar Buttons Run p Halt Animate DD Step Into m Step Over te Step Out im Reset 4 2 91 REAL TIME MODE Open the PIC16F917 Debug Demo asm file 1 Double click on the PIC16F917 Debug Demo asm file from the Project Window or select File Open from the toolbar menu 2 Select Debugger gt Run or click the Run button 3 Turnthe 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 PIC16F917 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 Resetto reset the program DS51553B page 34 2006 Microchip Technology Inc PICkit 2 Debug Express 4 2 10 Debugging the PIC16F917 Debug Demo Code Any of the following issues can prevent the PIC16F917 Debug Demo program from working properly The A D converter value is not being written properly to the Delay routine The A D converter is not enabled or has not been set to convert A typing error in the source code has caused the program to function improperly To explore the first listed
16. 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 2839 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 Singap
17. DAT PGD 5 ICSPCLK PGC 6 Auxillary gt O1 Q N 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 laynard connection is available on the programmer 2006 Microchip Technology Inc DS51553B page 9 PICkit 2 User s Guide 1 6 PROGRAMMING SOFTWARE Start the PICkit 2 Programming Software by selecting Start gt Programs gt 2 Microcontroller Programmer gt PICkit 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 File Device Family Programmer Tools Help 41 Menu Bar r Midrange Device Configuration Configuration Word Ox3FFF Ox3FFF OSCCAL 8 Device Configuration UserlD s Ox7F7F7F7F Banda CheckSum Dx3DFE PICkit 2 Firmware Version 1 21 00 4 Status Bar Progress Bar 5 Write Verify Erase Blank Check Target 5 07 Program memory Source empty erased 3FFF 3FFF 0008 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0010 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0018 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0020 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3
18. Debug Demo asm Select and highlight the PIC16F917 Debug Demo asm file and click the Add button The file will be placed into the right pane window 2 Click the check box next to the file to copy the file into the project directory 3 Next add the linker script file Go to C Program File Microchip MPASM Suite LKR 16F9171i Ikr Make sure and select the file with the i Select and highlight the 1691 7i Ikr file and click the Add button 4 Click the check box next to the file to copy the linker script file into the project directory 5 Click Next to continue to the Summary window Note Files can be added later if needed FIGURE 4 12 ADD FILES Project Wizard x Step Four E Add any existing files to your project do 16913 Eile C Program Files Microchip MP 16 913ilk E 1681 PIC16F917 Debug Demo asm C B 16 9140 ME uj E 1 1 Remove E 16f916i kr 16f917 kr E 16f946 lkr 16f946ilkr 2l E pede d Check the box to copy the file to the B 16hv Je project directory Click the filename to V edit the name of the local copy Back Cancel Help If any errors have been made click on the Back button to return to any ofthe previous steps in the Project Wizard Click Finish FIGURE 4 13 PROJECT SUMMARY Summary Click Finish to create the project with these parameters Project Parameters
19. Delay l 2 1 Waste time The Inner loop takes 3 instructio incfsz Delay tl f hi er op tak and addition goto AZDDelayLoop o TenmSdelay SSooee Or OrCFr c O r m ns IO Fc a r css 54 2006 Microchip Technology Inc DS51553B page 37 PICkit 2 User s Guide 13 FIGURE 4 27 Examine the values of the ADCONO and ADCON 1 registers in the Watch window The ADCONO value is 0x00 b 00000000 This corresponds to the hex value designated in the program However this is not correct A review of the PIC16F917 916 914 913 Data Sheet 0541250 Analog to Digital A D Con verter Module section indicates that the last bit should be a 1 b 00000001 to turn on the A D module To fix this bug change movlw 0x00 to movlw 0x01 as shown in Figure 4 27 A D MODULE CODE C Program Files Micre STARTUP code pagesel Main goto Main ode Mair bsf STATUS RPO select Register Page 1 movlw OxFF movwt TRISA clrf TRISD movlw 0 10 movwf ADCONI address LTUS RPO Register Page 2 configure Port pin 0 Analog address Register Page 0 0 01 ADCONO 0 80 configure 2 for Channel 0 Left justified and Looking for a 0 on the button Copy the display to the LEDs rait SuS for AZD amp to settle and capacitor to charge off 14 15 17 18 Selec
20. Device PIC16F917 Toolsuite Microchip MPASM Toolsuite File C Program Files Microchip PICkit new workspace will be created and the new project added to that workspace 2006 Microchip Technology Inc DS51553B page 29 PICkit 2 User s Guide 4 2 5 PIC16F917 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 FIGURE 4 14 PROJECT WINDOW PESO TT El C PIC16F917 Debug Dem Source Files 3 6 917 Debug C Header Files C object Files Library Files EC Linker Scripts 16F917ikr C3 Other Files 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 EESU E PIC16F917 Debug Dem F ag Add Files Filter CJ object Files Library Files E C2 Linker Scripts Z 16F917i Ikr other Files DS51553B page 30 2006 Microchip Technology Inc PICkit 2 Debug Express 4 2 6 Creating 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
21. EM File Device Family Programmer Tools About Midrange Device Configuration Code Protect Device Device PIC16F690 Device Power Check Board User ID s Ox7F7F7F7F CheckSum 0 050 j Download PICkit 2 Operating System Step 3 Browse to the directory where the latest Operating System code was saved as shown in Figure 5 2 Step 4 Select the PK2 hex file and click on the Open button FIGURE 5 2 SELECT PICkit 2 OPERATING SYSTEM Select PICkit 2 Operating System download a 2 x Look in y PICKit 2 1 a PK2v010000 hex File name PK2 hex hs M Files of type PICKit 2 Hex files PK2 he Y Cancel il files x 2 progress of the OS update will displayed the status bar of the programming software and the Busy LED on the PICkit 2 Microcontroller 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 2006 Microchip Technology Inc DS51553B page 41 PICkit 2 User s Guide NOTES DS51553B page 42 2006 Microchip Technology Inc PICkit 2 USER S GUIDE Chapter 6 Troubleshooting 6 1 INTRODUCTION This chapter describes questions and answers to common problems associated with using the PICkit 2 Microcontroller Programmer and h
22. FFF 3FFF 0028 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0030 3FFF 3FFF 3FFF Program Memory 0038 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0040 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0048 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0050 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0058 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0060 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF iz FF FF FF 008 FF FF FF FF FF FF FF FF 010 FF FF FF FF FF FF FF Data EEPROM Memory 018 FF FF FF FF FF FF FF 020 FF FF FF FF FF FF FF FF 028 FF FF FF FF FF FF FF FF z MiCROCHIP DS51553B page 10 2006 Microchip Technology Inc PICkit 2 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 Import File Import a hex file for programming Export File Export a hex file read from a device Exit Exit the program duplicated with the Quit button DEVICE FAMILY Baseline 12 bit Core Configures the programming software for baseline Flash devices Mid range 14 bit Core Configure the programming software for mid range Flash devices PIC18 Configures the programming software for PIC18F Flash devices future feature presently grayed out PIC18J Configures the programming software for PIC18FXXJXX Flash devices future feature presently grayed out dsPIC DSC Configures the pro
23. MMER 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 PICkitTM 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 is for initiating a function that will be implemented in the near future DS51553B page 8 2006 Microchip Technology Inc PICkitTM 2 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 Circuit Serial Programming ICSPTM refer to Chapter 3 PICkit 2 and FIGURE 1 2 PICkit 2 CONNECTOR PINOUT Pin 1 Indicator Pin Description 12 VPP MCLR 22 VDD Target Vss ground 4 2 ICSP
24. VALUE lll C Program Files Microchip PICkit 2 PIC16F917 Deb clrf LookingFor Lo MainLoop movf Display w Cc mowvvrf PORTD nop va nop wa nop wa nop wa nop va bsf ADCONO GO DONE st btfsc ADCONO GO_DONE th goto f l movf ADRESH w Co E movvrf Delayt bons 027 AZDDelayLoop mi incfsz Delav f Waste time 6 Adjust the POT and continue the program by selecting Debug gt Run The program will run through the loop and halt 7 Hover 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 MainLoop movf Display w Copy the display to the LEDs mowwf PORTE nop wait Sus nop a nop nop settle and capacitor to c nop wait bsf DCONO GO DONE start btfsc goto 1 movf ADRESH w Copy the AZD result to the delay loop movwf Delayil ion 0 DONE this bit will change to zero when the AZDDelayLoop incfsz Delay f Waste time The Inner loop t goto incfsz goto movlw TenmSdelay decfsz goto decfsz goto btfsc LookingFor O zi 8 Select Debugger gt Reset to reset the program The first instruction should indicated by a green arrow 9 Select View gt Watchto open a new Watch window This window allows the user to watch the A D register value change as the
25. circuit debugging allows the designer to run examine and modify the program while the 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 40 version or later 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 0551519 MPLAB IDE Quick Start Guide 0551281 MPLAB IDE On line Help 2006 Microchip Technology Inc DS51553B page 23 PICkit 2 User s Guide 4 2 1 Selecting the Device and Development Mode From the MPLAB IDE menu bar select the PICmicro MCU device for this tutorial 1 Select Configure gt Select Device FIGURE 4 1 MPLAB IDE MENU BAR Build Version Control Find in Files MPLAB IDE v7 41 I File View Project Debugger Programmer Tools Configure Window Help 2 Select Device Configuration Bits E
26. crochip MPAS MPLINK 4 04 Linker Copyright 2006 Microchip Technology Inc Errors 0 MP2COD 4 04 COFF to COD File Converter Copyright c 2006 Microchip Technology Errors 5 0 MP2HEX 4 04 COFF to HEX File Converter Copyright 2006 Microchip Technology Inc Errors Loaded C AProgram Files Microchip PICkit 2 PIC16F91 Debug Demo cof BUILD SUCCEEDED Mon Aug 14 14 36 58 2006 2006 Microchip Technology Inc DS51553B page 31 PICkit 2 User s Guide 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 Select Configure gt Configuration Bits 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 Oscillator INTOSC Watchdog Timer Off Power Up Timer On MCLR Pin Function Select Normal Function Code Protect Off Data EE Protect Off Brown Out Detect BOD enabled SBODEN disabled Internal External Switch Over Disabled Fail Clock Monitor Enable Disabled FIGURE 4 18 CONFIGURATION BIT SETTINGS Configuration Bits n x Oscillat
27. ctions 12 HIGHLIGHTS This chapter discusses The PICkit 2 Contents The PICkit 2 Overview 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 2 Starter Kit CD ROM 1 44 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 2 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 at www microchip com Note PICkit 2 Microcontroller Programmer is intended for development programming For production programming please consider the MPLAB Programmer or other third party programmers designed for the production environment 2006 Microchip Technology Inc DS51553B page 7 PICkit 2 User s Guide 1 5 PICkit 2 MICROCONTROLLER PROGRAMMER OVERVIEW The PICkit 2 Microcontroller Programmer overview is shown in Figure 1 1 FIGURE 1 1 PICkit 2 MICROCONTROLLER PROGRA
28. e check box next to the Program Memory window controls whether the program memory will be programmed into the device or not If the box is checked the code displayed in the Program Memory window will be programmed into and used to verify the device If the box is not checked the program memory will not be programmed and it will not be used to verify the device 1 6 6 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 cannot be edited in the window The check box next to the Data EEPROM Memory window controls whether the data EEPROM memory will be programmed into the device or not If the box is checked the code displayed in the Data EEPROM Memory window will be programmed into and used to verify the device If the box is not checked the data EEPROM memory will not be programmed and it will not be used to verify the device r r r r r r r r r S DS51553B page 12 2006 Microchip Technology Inc PICkit 2 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
29. ed trademarks of Microchip Technology Incorporated in the U S A Analog for the Digital Age Application Maestro CodeGuard dsPICDEM dsPICDEM net dsPICworks ECAN ECONOMONITOR FanSense FlexROM fuzzyLAB In Circuit Serial Programming ICSP ICEPIC 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 2006 Microchip Technology Incorporated Printed in the U S A All Rights Reserved Printed 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 8 bit MCUs KEELOG 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 DS51553B page ii 2006 Microchip Techn
30. ee vou us 22 Chapter 4 PICkit 2 Debug Express 4 1 Inirod Cti n MEET 23 4 2 PIGKIL 2 Debug EXDIBSS Seer tee 23 4 2 1 Selecting the Device and Development Mode 24 4 2 2 PICkit 2 Microcontroller Programmer Debug Tool 25 4 2 3 Updating PICkit 2 Firmware Operating System 26 4 2 4 Running the Project Wizard 27 4 2 5 PIC16F917 Debug Demo Project 30 4 2 6 Creating a Hex File iii 31 4 2 7 Setting Debug 32 4 2 8 Loading Program Code for Debugging 2 32 4 2 9 PIC16F917 Debug Demo sese 34 4 2 10 Debugging the PIC16F917 Debug Demo Code 35 4 2 11 Programming the Application 38 Chapter 5 Updating the PICkit 2 Operating System 5 1 IMTOdUCTION es 41 5 2 Updating the PICkit 2 Microcontroller 41 Chapter 6 Troubleshooting 6 1 INtrodUCtON uro aseo E cea e n bec iS 43 6 2 Frequently Asked Questions edet ee oe eril redes 43 Appendix A Hardware Schematics Introduction sus ette mo ttti the mI na eI DES 45 Worldwide Sales and Service
31. er gt Select Tool gt None 2 Select PICkit 2 Microcontroller Programmer as the programmer in Programmer 2 Select Tool menu 3 Optional Set up the ID in Configure ID Memory FIGURE 4 28 CONFIGURE ID MEMORY LA HV Jammer Tools Configure Window Help Select Device Configuration Bits Extemal Memory Settings FIGURE 4 29 USER ID MEMORY Me x User ID Use Unprotected Checksum Cancel Help 4 Setup the parameters for programming on the Programmer gt Settings Program tab 5 Select Programmer gt Program Now the PICkit 2 Microcontroller Programmer can reset and run the target 2006 Microchip Technology Inc DS51553B page 39 PICkit 2 User s Guide NOTES DS51553B page 40 2006 Microchip Technology Inc PICkit 2 USER S GUIDE Chapter 5 Updating the PICkit 2 Operating System 5 1 INTRODUCTION This chapter describes how to update the PICkit 2 Microcontroller Programmer s operating system 5 2 UPDATING THE PICkit 2 MICROCONTROLLER PROGRAMMER To update the PICkit 2 Microcontroller Programmer firmware Operating System complete the following steps Step 1 Download the latest PICkit 2 Operating System from the Microchip web site at www microchip com Step 2 From the menu select Tools Download PICKit 2 OS Firmware as shown in Figure 5 1 FIGURE 5 1 DOWNLOAD PICkit 2 OPERATING SYST
32. ersion Control Find in Files PICKit 2 Initializing PICkit 2 version 0 0 0 16 Found PICkit 2 Operating System Version 1 10 7 Target power not detected Powering frorn PICkit 2 found Rev 0 4 PICkit 2 Ready 4 Select Debugger gt Settings to setup the PICkit 2 Microcontroller Programmer operation 5 Click the Connect on Startup check box to enable the auto connection feature 6 Click Ok FIGURE 4 5 PICkit 2 MICROCONTROLLER PROGRAMMER SETTINGS 2 Settings 2 Settings Warnings l Automatically Connect on startup Program after a successful build Run after a successful program Output to debug file OK Cancel Apply 2006 Microchip Technology Inc DS51553B page 25 PICkit 2 User s Guide 7 Select Debugger Connectto connect to the PICkit 2 Microcontroller Program mer The Output window displays communication status between the PICkit 2 Microcontroller Programmer and Target Board FIGURE 4 6 PICkit 2 MICROCONTROLLER PROGRAMMER CONNECT gl xl Build Version Control Find in Files PICKit 2 Initializing PICKit 2 version 0 0 0 16 Found PICkit 2 Operating System Version 1 10 7 Target power not detected Powering from PICkit 2 1 found Rev 0 4 PICkit 2 Ready Found PICkit 2 Operating System Version 1 10 7 Target power not detected Powering from PICkit 2 fou
33. ervisory circuits with ICSP see Application Note AN820 System Supervisors in ICSP Architectures 0500820 3 2 2 If the VPP pin is used as an I O port 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 PGD isa bidirectional synchronous serial programming data line If the design permits dedicate these pins for ICSP However if the application circuit requires that 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 DS51553B page 20 2006 Microchip Technology Inc PICkit 2 and ICSP 3 4 VDD During ICSP programming the PICmicro MCU needs to be powered in accordance with the device specification Typically the MCU supply voltage is connec
34. f 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 PICmicro MCU the application circuit needs to take into consideration the bulk erase voltage requirement while protecting any voltage sensitive circuitry 2006 Microchip Technology Inc DS51553B page 21 PICkit 2 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 PICmicro MCU as possible Minimize any cable length between the PICkit 2 Microcontroller Programmer and application circuit PlCmicro MCU The goal is to keep the ICSP signals within the level and slew rate specifications for successful programming H n c ag M SF DS51553B page 22 2006 Microchip Technology Inc MICROCHIP PICkit 2 USER S GUIDE Chapter 4 PICkit 2 Debug Express 41 INTRODUCTION The PICkit 2 Microcontroller Programmer allows in circuit debugging on selected PIC micro Microcontroller Units MCUs In
35. gistration Card entitles users to receive new product updates 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 development tool to emulate and debug firmware on a target board Low Pin Count Demo Board s 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 Programming ICSP Guide 0530277 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 Describe
36. gramming software for dsPIC DSC Flash devices future feature presently grayed out PROGRAMMER 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 Con figuration 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 PIC12F629 675 and PIC16F630 676 only Blank Check Performs a blank check of program memory data EEPROM memory ID locations and Configuration bits Full Erase OSCCAL and BG erased Performs bulk erase including the OSCCAL and Band Gap BG values PIC12F629 675 and PIC16F630 676 only Regenerate OSCCAL Regenerates the OSCCAL value only for PIC12F629 675 and PIC16F630 676 The AUX line must be connected to the RA4 T1G pin Set Band Gap Calibration Value Sets the band gap value only for PIC12F629 675 and PIC16F630 676 TOOLS Code Protect Device Enables code protection features of the microcontroller on future write operations Target Power Power target from PICkit 2 Microcontroller Programmer Check Board Verifies communication with the PICkit 2 Microcontroller Programmer and reads the device ID of the target MCU Download PICkit 2 Operati
37. groups Microchip consultant program member listing Business of Microchip Product selector and ordering guides latest Microchip press releases listing of seminars and events listings of Microchip sales offices distributors and factory representatives 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 MPASMTM and MPLAB ASM30 assemblers MPLINKTM 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 s
38. he Active Toolsuite drop down menu Note Make sure the tools are set to the proper executables by default in the C Program Files Microchip MPASM Suite folder as follows MPASM Assembler should be pointing to mpasmwin exe MPLINK Linker should be pointing to mplink exe MPLIB Librarian should be pointing to mplib exe 6 Click Next to continue to Step Three FIGURE 4 10 STEP TWO gt Step Two Select 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 MP4SM Suite MP smwin exe Browse Help My Suite Isn t Listed Show all installed toolsuites n Step Three type in the name and location of the project or click the Browse button to locate the project files Click Next to continue to Step Four FIGURE 4 11 STEP THREE Project Wizard gt Step Three B Name your project wA r Project Name PIC16F917 Debug Demo Project Directory C Program Files Microchip PICkit 2 Browse DS51553B page 28 2006 Technology Inc PICkit 2 Debug Express In Step Four add the project files 1 From the left pane window go to C Program Files Microchip PICkit 2 PIC16F917
39. imulator MPLAB IDE Project Manager 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 1 development programmers 2006 Microchip Technology Inc DS51553B page 5 PICkit 2 User s Guide CUSTOMER SUPPORT Users of Microchip products can receive assistance through several channels Distributor or Representative Local Sales Office Field Application Engineer FAE Technical Support Development Systems Information Line 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 Initial release of this document Revision B August 2006 Updated Preface added Chapter 4 PICkit 2 Debug Express tutorial RC rr n F n DS51553B page 6 2006 Microchip Technology Inc PICkit 2 USER S GUIDE Chapter 1 PICkit 2 Overview 11 INTRODUCTION This chapter introduces the PICkit 2 Microcontroller Programmer and describes the PICkit 2 Microcontroller Programmer features and menu fun
40. k you may have a right to sue for relief under that Act Information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates It is your responsibility to ensure that your application meets with your specifications MICROCHIP MAKES REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED WRITTEN 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 register
41. ly programmed in the upper pro gram memory of the PIC16F917 target device for the PICkit 2 Microcon troller Programmer debug functions Debug code must be programmed into the target PlCmicro MCU to use the in circuit debugging capabilities of the PICkit 2 Microcontroller Programmer FIGURE 4 20 OUTPUT WINDOW 2 MICROCONTROLLER PROGRAMMER TAB maOuput D Build Version Control Find in Files 2 Initializing PICKit 2 version 0 0 0 16 Found PICkit 2 Operating System Version 1 10 7 Target power not detected Powering from PICkit 2 PIC16F91 found Rev 0 4 PICkit 2 Ready Programming Target 8 14 2006 3 24 31 PM Erasing Target Programming Debug Executive 0 1 00 0x1 FFF Verifying Debug Executive 0 1 00 x1FFF Programming Debug Vector Verifying Debug Vector Programming Configuration Memory Verifying Configuration Memory Debug mode entered DE Version 1 0 8 PICkit 2 Ready va FrcrrtsII sc s s s sss lt sqhs sI r n s M n 2006 Microchip Technology Inc DS51553B page 33 PICkit 2 User s Guide 4 2 9 PIC16F917 Debug Demo The PICkit 2 Microcontroller Programmer executes in either Real Time or Step mode Real Time execution occurs when the PIC16F917 on the 44 Pin Demo Board is in the MPLAB IDE Run mode Step mode execution can be accessed after the processor is halted The following toolbar buttons can be
42. nd Rev 0 4 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 FRMWARE DIALOG cs 218 Build Version Control Find in Files PICkit 2 Initializing PICkit 2 version 0 0 0 12 Found PICkit 2 Operating System Version 1 20 0 Downloading PICkit 2 OS 1 10 7 DS51553B page 26 2006 Microchip Technology Inc PICkit 2 Debug Express 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 FIGURE 4 8 PROJECT WIZARD welcome This wizard helps you create and configure a new MPLAB project To continue click Next lt Back Cancel Help 3 Select the PIC16F917 device from the Device drop down box 4 Click Next to continue to Step Two FIGURE 4 9 STEP ONE Project Wizard x Step One j device 8 Device PIC16F91 se pers 2006 Microchip Technology Inc DS51553B page 27 PICkit 2 User s Guide 5 Select MPASM Toolsuite from t
43. ng System Performs a download of the PICkit 2 Microcontroller Programmer firmware operating system ABOUT Displays a dialog box indicating the version and date 2006 Microchip Technology Inc DS51553B page 11 PICkit 2 User s Guide 1 6 2 Device Configuration The Device Configuration window displays the MCU device User ID Configuration Word and Checksum It also displays OSCCAL and Band Gap which are available only on PIC12F629 675 and PIC16F630 676 devices For mid range 14 bit core devices the PICkit 2 Microcontroller Programmer reads the device ID and displays it in the window For baseline 12 bit core devices the user must select the device from the Device drop down menu 1 6 3 Status Bar The status bar displays text status of the operations in progress If an operation is successful the status bar will display a green background If an operation fails the status bar will display red If an operation alerts a caution the status bar will display yellow 1 6 4 Progress Bar The progress bar displays the progress of an operation 1 6 5 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 cannot be edited in the window Th
44. ology Inc MICROCHIP PICkit 2 USER S GUIDE Table of Contents 1 1 Chapter 1 PICkit 2 Overview PEE TT 7 1 2 wa Ya LL S AA Ra 7 1 3 PICKit 2 Microcontroller Programmer Contents 7 1 4 Introducing the PICkit 2 Microcontroller Programmer 7 1 5 PICKit 2 Microcontroller Programmer Overview 8 1 5 1 USB Port Connection iii 8 1 5 2 Status be pie oe tn eee Ideni 8 1 5 3 TEES 8 1 5 4 Programming Connector 9 1 5 5 Lanyard Connection sis 9 1 6 Programming Software 10 6 21 Potter ie hag eet ete ANE DORA NE a 11 1 6 2 Device Configuration iot ushayku sta 12 1 6 9 otatus ROSE ne AA 12 1 6 4 Progress Bar iii 12 1 6 5 Program Memory 12 1 6 6 Data EEPROM Memory iii 12 Chapter 2 Getting Started ZA uicit 13 2 2 Installing the PICkit 2 Programming Software 13 2 3 Using the PICkit 2 Programming Software 2 13 2 3 1 Selecting the Device Family
45. ontroller Programmer will automatically read the device ID word from the MCU and display it in the Configuration window as shown in Figure 2 3 FIGURE 2 3 IDENTIFY DEVICE PICkit 2 Microcontroller Progra er File Device Family Programmer Tools About r Midrange Device Configuration Device PIC16F690 UserlD s Ox7F7F7F7F posue CheckSum OxFFFF ia ar Read Write Verify Erase Quit Target Power If the Baseline 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 Configuration Word Ox3FFF n CAUTION 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 Microcontroller Programmer File Device Family Programmer Tools About Baseline Device Configuration Device Configuration Word OxOFFF User ID s T Bee ee CheckSum 0 202 andaa 204 PIC10F206 DS51553B page 14 2006 Microchip Technology Inc Getting Started 2 3 3 Target Power The PICkit 2 Microcontroller Programmer can supply power to the target To enable power to the target device
46. or INTOSC Watchdog Timer Off Power Up Timer On MCLR Pin Function Select Normal Function Code Protect Off Data EE Read Protect Off Brown Out Detect BOD Enabled SBODEN Disabled Internal External Switch Over Disabled Fail Clock Monitor Enable Disabled 4 2 8 Loading Program Code for Debugging Select Debugger gt Select Tool gt PICkit 2to select the PICkit 2 Microcontroller Programmer as the debug tool Select Debugger Program to program the PIC16F917 Debug Demo hex file into the PIC16F917 on the 44 Pin Demo Board DS51553B page 32 2006 Microchip Technology Inc PICkit 2 Debug Express FIGURE 4 19 6 917 Debug Demo MP File Edit View Project Debugger Programmer Select Tool Clear Memory L JPICIGF91 z Ru F9 Animate E LA PIC16F917 Det gc Source Files Step Into 2 PIC16F9 Step Over C Header Files Step Gut J Object Files Reset aaa I Library Files EC Linker Scripts E 16 917 10 22720 J Other Files Read Read EEDATA Breakpoints F2 Connect 4 Download 05 J Files f Symbols Settings Programming will only take a few seconds During programming the PICkit 2 Microcontroller Programmer tab of the Output dialog window will display the current phase of operation When programming is complete the dialog should look similar to Figure 4 20 Note The debug executive code is automatical
47. ore 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 3910 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 08 29 06 DS51553B page 48 2006 Microchip Technology Inc
48. ow to resolve them 6 2 FREQUENTLY ASKED QUESTIONS Device is not recognized Question Why l receiving an Insert Device 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 PICkitTM 2 and ICSPTM Current Limit Exceeded Question Why am l receiving the error message USB Hub Current Limit Exceeded from the Microsoft Windows program Answer Check for shorts on the circuit board Microsoft Windows Driver Question After plugging the PICkitTM 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 MPLAB ICD 2 USB driver Verify and Read Return all Zeros Question When the Verify or Read 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 2006 Microchip Technology Inc DS51553B page 43 PICkit 2 User s Guide Microsoft Windows 95 98 NT Que
49. 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 Highlight the following line of code in the PIC16F917 Debug Demo 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 movlr 0 01 0 configure AZD for Channel 0 RAO Left j on LookingFor Looking for 0 on the button MainLoop movf Display w Copy the display to the LEDs movwt PORTD SuS for AZD amp to settle and capacitor to 1 us start conversion this bit will change to zero movf ADRE 2 result to the delay B movwf Delaytl AZDDelayLoop Waste time The Inner loop takes 3 cocoa 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 Hover over ADRESH in the listing file and it will show the value of the file register see Figure 4 22 incfsz Delay goto A2DDelayLoop ss 2006 Microchip Technology Inc DS51553B page 35 PICkit 2 User s Guide FIGURE 4 22 ADRESH REGISTER
50. r s Guide DOCUMENT LAYOUT This document describes how to use the PICkit 2 Microcontroller Programmer as development tool to emulate and debug firmware on a target board The manual layout is as follows Chapter 1 PICkitTM 2 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 PICmicro Microcontroller Units MCUs Chapter 3 PICkit 2 and ICSP Describes programming with the PICkit 2 Microcontroller Programmer using In Circuit Serial Programming ICSP Chapter 4 PICkit 2 Debug Express Provides a tutorial on using the PICkit 2 Debug Express debugger program Chapter 5 Updating the PICkit 2 Operating System Provides instruction on how to update your PICkit 2 Microcontroller Programmer s Operating System Chapter 6 Troubleshooting Provides information on solving common problems Appendix A Hardware Schematics Illustrates the PICkit 2 Microcontroller Programmer hardware schematic diagrams DS51553B page 2 2006 Microchip Technology Inc Preface CONVENTIONS USED IN THIS GUIDE This manual uses the following documentation conventions DOCUMENTATION CONVENTIONS Description Represents Examples Arial font Italic characters Referenced books MPLAE
51. rase the device click the Erase button Note The PICkit 2 Microcontroller Programmer uses the bulk erase method that requires VDD voltage between 4 5 to 5 5V PC oss Ga rc a cw KR u DS51553B page 18 2006 Microchip Technology Inc PICkit 2 USER S GUIDE Chapter 3 PICkit 2 ICSPTM 31 INTRODUCTION The PICkit 2 Microcontroller Programmer can program 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 CSPDAT or PGD Programming Data a bidirectional synchronous serial data line VpD Power Supply positive voltage Vss Power Supply ground reference However the application circuit must be designed to allow all the programming signals to be connected to the PICmicro 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
52. s how to use the Microchip PICmicro 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 Debug Express txt file an ASCII text file in the Readmes sub directory 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 OCC sua DS51553B page 4 2006 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 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
53. stion Can run on Windows 95 98 NT Answer No These operating systems either do not support USB or have drivers that are not compatible rr rr r nr s lt sFh DS51553B page 44 2006 Microchip Technology Inc PICkit 2 USER S GUIDE MICROCHIP Appendix A Hardware Schematics INTRODUCTION A 1 This appendix contains PICkit 2 Microcontroller Programmer schematic diagrams PICkit 2 MICROCONTROLLER PROGRAMMER SCHEMATIC DIAGRAM PAGE 1 OF 2 FIGURE A 1 0 2 vas t g VOS Ss VdS gsvas SSA Y Dos 91108 wig 0952 5105 ve dM dM Whe gt Wis 8 99 8202 rl us uso mu 6 m 8sn AS gun y ON TL mro L mro vA oL vA OL asn 69 1H o E 019 SH 2 gsn AS gsn 9 gsn AS 2 T 191 A te 5001 4n vo gsn AS Ley 89 5 5 W y T AMY gi OdS LaKuizow ZOPONTH h100949N V 0L M gt SS LD 2 ns mol 9L dA G 824 SSA 8 Z 19 sy Myo gana YA yo LdoO zou 4 85 99 191 21 es ace j PIDELJOSOLLODA gz dodelanizay V
54. t File gt Save to save the changes Select Project gt Build All to rebuild the project A message will indicate that the program has been rebuilt The PICkit 2 Microcontroller Programmer must be reprogrammed for the changes to take effect Select Debugger gt Program to reprogram the PICkit 2 Microcontroller Program mer with the changes When the PICkit 2 Microcontroller Programmer dialog indicates Programming Succeeded the program is ready to run again Right click on the line of code that previously had the breakpoint and select Remove gt Breakpoint Select Debugger gt Runto 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 Microcontroller Programmer and MPLAB IDE debugging functions users can successfully find and fix problems in their code 4 2 11 Programming the Application When the program is successfully debugged and running the next step is to program the 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 1 Disable PICkit 2 Microcontroller Programmer as a debug tool by selecting DS51553B page 38 2006 Microchip Technology Inc PICkit 2 Debug Express Debugg
55. ted 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 2 Microcontroller Programmer The PICkit 2 Microcontroller Programmer supply voltage VDD is 5V If the application circuit operates at a different voltage isolation circuitry may be required so that the two voltage levels do not conflict CAUTION The PICkit 2 Microcontroller Programmer supply voltage Vpp is 5V CAUTION The USB port current limit is set to 100 mA If the target plus PICkit 2 Microcontroller Programmer exceeds this current limit the USB port will turn off The target be powered externally if more power is required 3 4 2 The application circuit is powered externally The PICkit 2 Microcontroller Programmer supply voltage VDD is 5V If the application circuit operates at a different voltage isolation circuitry may be required so that the two voltage levels do not conflict CAUTION The PICkit 2 Microcontroller Programmer supply voltage VDD is 5V 3 4 3 Bulk Erase is used Some MCU devices use 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 o
56. the Microchip web site at www microchip com FIGURE 3 1 TYPICAL ICSPTM APPLICATION CIRCUIT Isolation Circuitry Resistor Schottky type diode PICKit 2 Programming 5V Header 1 vee MCLR y e VDD gt Vss ICSPDAT PGD gt ICSPCLK PGC y 45V AUX gt v 10e 2 470 Ohm 4 MM LM VDD Vsse4 OR 21 5 AAA To Application SiRa4 RAIICSPCLK L LAW Circuit 4lRAS MCLR VPP 25 70 1 uF Target Microcontroller Device Typical Values 2006 Microchip Technology Inc DS51553B page 19 PICkit 2 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 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 sup
57. xternal Memory ID Memory Settings 2 Click on the Device drop down list and select the PIC16F917 device No other changes need to be made in this dialog box 3 Click OK FIGURE 4 2 SELECT DEVICE Device PIC16F870 PIC16F871 PIC18F872 PIC16F873 PIC16F873A PIC16F 874 PIC16F 874A PIC16F 876 PIC16F 876A PIC16F877 PIC16F877A PIC16F88 PIC16F883 PIC16F884 PIC16F886 PIC16F887 PIC16F913 PIC16F914 PIC16F916 PIC16F946 PIC16HV540 PIC17C42 PIC17C42A PIC17C43 PIC17C44 PIC17C752 PIC17C756 PIC17C756A Select Device Device Family MPLAB ICD 2 PICkit 1 PIC17C762 DS51553B page 24 2006 Microchip Technology Inc PICkit 2 Debug Express 4 2 2 PICkit 2 Microcontroller Programmer Debug Tool Select the PICkit 2 Microcontroller Programmer as the debug tool Select Debugger Select Tool 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 MPLAB IDE v7 41 File Edit View Project Debugger Programmer Tools Configure Window Help v None DE ki 5 Ma Clear Memory 1 MPLAB ICD 2 DUNT RE 2 MPLAB ICE 4000 3 MPLAB SIM 4 MPLAB ICE 2000 RS I Build CRT Version Control Find in Files FIGURE 4 4 OUTPUT WINDOW Build V
Download Pdf Manuals
Related Search
Related Contents
Haier ESA3085 User's Manual 取扱説明書 Manual do Fax X5400 Series efrem raimondi, vasco rossi, i ritratti e il design dan chung e le Manuel d`entretien ZT710-ZT740 Istruzioni per l`uso TERRASEM 3000 T Standardline Intra-Pod instructions.ppt [Read-Only] viscount Copyright © All rights reserved.
Failed to retrieve file