Using the PICkit 2 : As a Programmer

PicKit2 Debug Express
PicKit2 Debug Express

Around the space, we have been using the PICkit 2 Debug Express quite a bit lately.  This has allowed us to get pretty cozy with the functions of this handy little programmer and I thought I would share some of these features with you.

I’m sure you’ve read the previous tutorial ‘Programming PIC Microcontrollers in C‘, if you haven’t, you should go familiarize yourself with it now.  Continuing on from there, after we have a successful build of a led blinking we can use the PICkit 2 to program our chip via the ICSP header.

Our Debug Express Kit’s came with a Demo Board which has a 44 pin PIC16F887 microchip. The microcontroller is connected to a 6 Pin Male header called the ICSP (In-Circuit Serial Programmer) header.  All PIC microcontrollers with the letter “F” in their name can be programmed this way, even if you are using a breadboard and wires to make the connections. The “F” stands for Flash.  Maybe in a future article we will show you how to construct the ICSP header from the data sheet, but we will just assume you are using the 44 Pin Demo Board for now.

You should already have the PICkit 2 connected to your PC via the USB port, so after a successful build of our program, we can program the chip by selecting the ‘Programmer’ menu from within MPLAB, and then selecting ‘Select Programmer’, then ‘PICkit 2′.

At that point below in the debug window you should see a message such as ‘Found PICkit 2 – Operating System Version 2.32.0 …’ If you do not, select ‘Programmer’ then ‘Connect’ from MPLAB.

Finally we select ‘Programmer’ then ‘Program’, and it should start erasing and programming the chip.

Lastly, one tip that speeds up the programming process is to go to the ‘Programmer’ menu and then click ‘settings’. Then check the boxes ‘Program after a successful build’ and ‘Run after a successful program’.  Once you do that you can just hit F10 to compile and flash the pic over and over as you make small adjustments to your code.

In the end, this simple task is actually quite convenient. Being able to program a chip in-circuit, instead of taking the chip out of the socket, putting it in a programmer, programming it, taking it out, putting it back into the other socket, turning on, etc.

Finally, an often overlooked feature is that the PICkit 2 will power your chip if it doesn’t detect any voltage, which for me personally is the case before I have a power supply set up.  I wouldn’t overdue it, you can power small things, led’s, tiny motors but don’t try to draw too much current from it.  The maximum power draw is 200-300mA less than the USB port puts out, which in most cases is around 500mA leaving you with 200-300mA.  So don’t try to overdue it, if you’ve got a lot of power draw in your circuit, set up your own power source and the PICkit 2 will detect the voltage during program and wont try to power it.

Happy Hacking!


Leave a Reply

%d bloggers like this: