Programming with the PICkit 2, a Breadboard, and ICSP
Programming your PIC without a demo board is a straightforward task, when you know what you’re doing (aren’t they all?). With the proper hardware, setting up your programmer should take almost no time at all. To do this, you will need two data sheets; the data sheet for the PICkit 2 and the data sheet for the PIC you plan on programming.
First, you need the proper hardware. This includes:
- The PICkit2 Programmer
- Two 6 position .100″ pitch male headers (Found at Digi-Key here)
- 6 position cable (an IDE cable works though its pitch is too narrow to be pretty)
- Breadboard with .100″ pitch holes. I believe this is standard.
But, wait, doesn’t the PICkit 2 data sheet show some resistors, capacitors, and even a diode? Yes, yes it does. However, those are all isolation circuitry. You only need those parts when you’re going to be putting other circuitry on the pins used for programming. If you aren’t going to use those pins for I/O, just connect them directly to the header without any additional circuitry. If so, follow the directions on the data sheet for the PICkit 2. From personal experience, the values used are very rough, so if you don’t have them on hand, use the closest you have and it will probably work. And, whatever you do, do not AC couple the Data or Clock programming lines to ground with a capacitor. Seems like common sense, but I was trying to decouple a node that I was sharing with the Clock and didn’t think things through. Don’t imitate my mistakes.
Second, find the proper pins on your PIC to attach to. Using Figure 3.1 from the PICkit 2 data sheet, you can see what signals are on each pin of the PICkit 2. Of the six pins, five are used. Ground (or VSS) and VDD are straightforward enough. VPP is a high voltage programming line which goes up to 12 volts to tell the microcontroller that it is being programmed. Then, the important pins are the Data and Clock lines.
The Clock line on the PIC’s data sheet will be denoted either by ICSPCLK (In Circuit Serial Programming CLocK) or PGC (ProGramming Clock). Again, make sure that there is not a capacitive load on this line or you will not be able to program your PIC.
The Data line on the PIC’s data sheet will be denoted either by ICSPDAT (In Circuit Serial Programming DATa) or PGD (ProGramming Data). This also needs to be free of a capacitive load.
All you need to do is to wire the five active lines to five consecutive, free rows on your breadboard and you’ll be able to attach your male header easily to the board and then to the PICkit 2 programmer. Using the software is covered in another tutorial. Then, if you have multiple PICs you need to program, you can switch between the different PICs with ease.
See? Quite straightforward. All the information is in the data sheets but I hope I helped make them more intelligible and saved you some time scouring them for the important information.
Comments
Comment from Joshua
Time September 25, 2008 at 9:50 am
Jacob,
Thanks for visiting!
When I used the IDE cable, I just grabbed an old cable, snipped off the ends, and then separated six of the lines from the rest like string cheese. It was a little difficult to start, so I used a razor blade to start the cut, and then was able to pull it the rest of the way. If you try and cut the entire thing, you will most likely slice into something you don’t want to.
Hope that helps,
Josh
Comment from Chris
Time September 25, 2008 at 10:30 am
If you need more than just a couple of these cables, you can pick up six conductor flat cable from places like Mouser and DigiKey. With a quick glance, I saw some at Mouser’s site for about $11. Takes the headache out of cutting it yourself if you’re making multiple cables.
Comment from Jacob George
Time October 6, 2008 at 5:41 pm
hey guys thanks for your help
one more question once i place one header on the breadboard what happens to the other header and how is the pic kit 2 connected to the headers. is there soldering needed
Comment from Joshua
Time October 6, 2008 at 7:00 pm
The other header attaches to the PICkit2 programmer (the black, flat plastic box) where pin 1 is the side of the white arrow. To figure out which pin goes where, go here and page 21 has the information of how to hook things up properly. I’ll try and upload a copy of the data sheet soon since this link to is a third party. However, other than soldering your wires to your headers, there should be no soldering required.
Comment from F. Gosler
Time June 4, 2009 at 7:26 pm
Really great concept. Where did you get this content? Do you write everything yourself?
Comment from Joshua
Time June 4, 2009 at 10:11 pm
Thanks for the compliment, yes, we write everything ourselves. Almost everything comes from us struggling to do something and trying to figure things out. We have found other sites that talk about similar topics, but of course, they have a different perspective on things and different writing styles. Its my hope that if those sites aren’t clear on something, the way we explain something will make things click. We appreciate any feedback on the tutorials, anything to make them clearer and more useful.
Comment from Jacob George
Time September 25, 2008 at 9:08 am
guys great website
quick question though where did you get a 6 position IDE cable