Help with programming using PicKit 2

Discussion in 'Embedded Systems and Microcontrollers' started by ke5nnt, Dec 22, 2011.

  1. ke5nnt

    Thread Starter Active Member

    Mar 1, 2009
    384
    15
    I might just be blind and not finding what I need, cause believe me I've looked. I've had my new PicKit 2 for 4 days and have yet to get anything but an error message on the PICKit 2 programmer software when trying to do so much as read data off the microcontroller, let alone program one. So I succumb to the need to ask AAC for help.

    I've programmed plenty of pics in the past with my off-brand programmer via USB which has the handy slot for accepting a number of different PICs of varying pin counts, but the PICKit 2 has only the ICSP connectors, which I've tried to interface with a PIC to no avail. So my question is, can someone point me in the right direction here on how to program a MCU using the PICKit 2? Do I need to build a programmer that plugs into the PICKit? Not a problem if I do.
     
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Can you tell us more about your setup like which PIC you use. Are you using MPLAB? And what is your error messages.
     
  3. bertus

    Administrator

    Apr 5, 2008
    15,648
    2,348
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    The PICkit2 (and 3) has 6 pins on one end, only 5 of which are active for programming or debugging. They are on convienent 0.1" centers so you can just add a header on a board to plug in the PICkit as you need it. I usually use all 6 pins leaving one blank, and always mark the pin 1 side.

    These pins are:

    1: Vpp/MCLR Connect to the MCLR pin. This pin will go to a high voltage (1-13V) when active so make sure your target board can handle that.

    2: VDD The power pin. PICkits will supply some current, 0.1A or so, so they can directly power some small projects and certainly a PIC itself. They do allow you to power the target device yourself and not use this power.

    3: VSS The ground pin, just connect to ground.

    4: PGD: Program data pin. Can appear in many places on a target so check your part data sheet.

    5: PGC: Program clock pin. Can appear in many places on a target so check your part data sheet.

    6: No connect.

    You should make sure that PGD and PGC are not loaded down heavily so the PICkit can still drive them. I have also occasionally had a problem programming due to a large bypass capacitor on VDD.

    The PICkit2 also has a stand-alone program which also has some nice self-test features you can try.
     
  5. DerStrom8

    Well-Known Member

    Feb 20, 2011
    2,428
    1,328
    I would assume you just didn't connect it properly. It would help to know what processor you are using. From there, we could tell you which wire for ICSP goes to which pin(s).

    Regards,
    Der Strom
     
  6. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Also remember that PICKIT 2 is a in circuit programmer. So is is no need to take the PIC in and out of the circuit for programming. However it is some minor precautions that must be followed using in circuit programming. I highly recommend in circuit programming. Taking a chip in and out of a circuit may be very stressful for chip.
     
  7. ke5nnt

    Thread Starter Active Member

    Mar 1, 2009
    384
    15
    I suppose it figures that no sooner do I post here after 4 days of fiddling that I get it figured out. Thanks anyways guys. I guess since I have you all here, can someone explain something else to me?

    I know that the microchips come from the factory with an OSCAL value programmed into them for their internal oscillator (the models that have one). The PICKit 2 along with the programmer software does preserve this value right? I'm pretty sure my old programmer has all but wiped out all of the calibration values on my PICs and I know it's difficult to recalibrate them after that word has been wiped out. I'd like to know how to read the calibration value with the PICKit so I can save it in case they get erased.

    Thanks for all the help as always guys.
     
  8. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    You can read the ROM memory before programming and make note of the value/instruction stored on the top address.

    In the stand-alone app the status line reports the OSCCAL value.

    PICkit 2 also can reprogram this OSCCAL value in many devices.
     
  9. ke5nnt

    Thread Starter Active Member

    Mar 1, 2009
    384
    15

    I would be thrilled if you could explain this part further. Thank you.
     
  10. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    Have you found the PICkit2 Programmer V2.61 applet yet? (First item here in Downloads) Under the Tools menu there is the OSCCAL item to pick either Manually Set or Auto Regenerate.

    This may be available from MPLAB but I never saw it there.
     
    ke5nnt likes this.
  11. ke5nnt

    Thread Starter Active Member

    Mar 1, 2009
    384
    15
    I will have to double-check when I get home which version I'm using. But seems to me the OSCCAL feature is only available for the 12F629 and some other MCU (can't remember model right now). When I've got the 16F628A plugged in, the OSCCAL in the tools menu is greyed out, and not able to be selected. I'll check when I get home from work. Thanks!
     
  12. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    It's been a while since that thing has been upgraded so you probably have the most recent version, and it doesn't do that magic with every part.
     
  13. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    I would also not worry to much about the internal oscillator accuracy. The accuracy is not that bad. It will do for the hobbyist setup. In most settings. If you try to use it with a PIC with onboard UART. You might experience some problems. But I do not think your PIC have UART. So it does not matter at this point
     
Loading...