You are here
In Circuit Programming
What is ICSP?
ICSP stands for In-Circuit Serial Programming. More information can be found at http://ww1.microchip.com/downloads/en/DeviceDoc/30277d.pdf
Benefits of ICSP
- You may program your PIC while it is in your breadboard circuit
- You may program your PIC while it is on a soldered circuit board
- You will save time programming so you can write more code faster
- You can reset your circuit from your PC
- You can program surface mount PIC's that are on soldered circuit board
- You won't bend or break any pins
- You won't damage your PIC by placing it in your breadboard wrong
- With a remote desktop software like VNC, you can program your PIC from anywhere around the world.
- I can program my PIC in my living room on my laptop while I watch tv with my wife! (I keep my mess in my office)
Intro to ICSP & in-circuit programming
When I got started in micro-controllers and JAL, I needed to choose a programmer. At the time, I did not know anything about choosing a programmer, so I just went on ebay and bought one that is able to program many different PIC's.
For years, I used this programmer by putting my 16f877 chip into it, programming it, and putting it into my circuit. I broke pins and wasted a lot of time. Little did I know, my programmer has an ICSP output for in-circuit programming. My programmer even says ICSP on it, but I did not know what ICSP is.
Eventually I got sick and tired of moving my micro-controller back and forth from the breadboard to the programmer, and I had herd some talk about ICSP. I found a ICSP circuit on the net, and I took a harder look at my programmer, it has 6 pins sticking up labeled ICSP. However, I did not know what pin was what, they where not marked well, and I could not find info about my programmer. One of the pins was marked pin 1 on the programmer. If you know your ICSP pinouts already, you may skip to the circuit diagram.
I searched for 6-pin ICSP in Google and found that pinouts are different depending on the programmer. So, I took out my volt-meter and logic probe (and oscilloscope, although it is not needed) and measured the voltages off each pin while programming a chip and while not. I could see on the PCB that pin 3 is connected to ground and pin 6 is connected to nothing. Here's what I got:
|PIN #||While Idle||While Programming|
|4||5v||Pulsing 0v to 5v (random)|
|5||0v||Pulsing 0v to 5v (square wave)|
|6||not connected||0v - can see no connection on PCB|
Get the pin names
The pin names for ICSP are VPP1, LOW, DATA, CLK, VCC, GND. So lets match them up:
0v pin 6 must be pin “AUX”, I think this one is actually not connected
0v pin 3 must be pin “GND”
pin 1 is a programming enable pin, VPP1
pin 2 is 5v, mostly used to power a not powered circuit during programming.
pin 4/5 are pulsing pins. They must be “CLK” and “DATA” (you may have to guess which is which if you don't ave a oscilloscope.
Lets make a new chart. I believe most ICSP ports have pins in this order:
|PIN #||PIN NAME||While idle||While Programming|
|4||DATA||5v||Pulsing 0v to 5v (random)|
|5||CLK||0v||Pulsing 0v to 5v (square wave)|
|6||AUX||not connected||not connected|
Build a circuit with ICSP
VDD can be connected to your PIC’s 5v supply (as seen in the schematic below), but many programmers do not need this pin. If you do not need it you can disconnect it. I feel that it is more safe to disconnect it if you are not going to use it. You can test disconnecting this wire after you get ICSP working.
VDD is for power-off programming. Power-off programming does not work in my circuit because there is too much current drain. In my projects, I do use the VCC pin, and I will program my chips while my circuit power supply is ON.
GND must be connected to your circuits ground. Follow this circuit diagram:
Your done! Turn on your power supply and try to program your chip!