Understanding ICSP for PIC Microcontrollers

Understanding ICSP

Programming microcontrollers isn’t hard. Building a programmer makes a great first electronics project. The goal of this instructable is to explain the simple ‘in circuit serial programming’ method used with Microchip PICs.

Step 1: Why ICSP?

Programming a big DIP (through hole) chip is easy. Pop it into a socketed programmer, burn, and return to the application circuit. Test and repeat.Understanding ICSP

Things get more difficult with smaller (surface mount) chips. There are no standard sockets for QFN, SSOP, QFP, or even the large SOIC .300 packages. There are really expensive ($100s) clips that can attach to, and program, these chips. A different clip is needed for each chip type and pin count you use.

There is an alternative. Its called ICSP.
ICSP means ‘in circuit serial programmer(ing?)’. It is a way of programming a PIC while it is still attached to the application circuit. Thats right, no more chip swapping.

Why ICSP?
1. There are no programming sockets for small package chips. Clips are expensive.
2. Its a pain to move chips in & out of the programmer during development. Impossible for surface mount parts.

Step 2: What is ICSP?

Five connections are needed to program a PIC while attached to an application circuit. I add a 5 pin header to my circuit boards to make this connection quick and easy.

The basics of PIC programming.
Five connections are required to program a PIC. Power, ground, a programming voltage, clock, and data.

+ (Vdd)/-(Vss) These are the power & ground connections (Vdd, Vss). Pretty standard. If you are using a programmer with ‘real’ voltage levels (NOT a JDM2!), your application can run from its own power supply when programmed, eliminating these connections.

Vpp This is the programming voltage. PICs enter programming mode when ~13 volts are placed on the MCLR/Vpp pin (usually pin 1 on modern PICs, more on that below).

Clock/Data or PGC/PGD The clock and data lines are used to write and read the PIC firmware. These are usually the same pins as PORTB6 & PORTB7.

Exercise: Identify the ICSP connection points on the PICs in the pictures below.

If the PIC fits, wear it.
I get a lot of questions about my JDM2 design on instructables. The most frequent is “Will it program PIC X?’”‘ – here is how you can tell:Understanding ICSP 1

1) Look at the data sheet. Find the ‘Pin Diagram’ that looks something like the picture below.
2) Identify the location of the pins that must be connected for programming (Vpp, Vdd, Vss, Data, & Clock).
3) Look at the socket connection on the programmer. Can you match the required pins with a socket on the programmer?

Step 3: How ICSP?

Depending on your design, you can now make all the required connections and program your PIC. There are a few catches that you should know about. Design for ICSP is important. Microchip provides a nice PDF application note about designing for ICSP.

http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en011744

Here are some tips and examples of ICSP designs from my previous instructables.

Tip #1, Threat level: Important
Don’t connect anything else to the CLOCK and DATA pins (usually RB6 & RB7, PGC & PGD).
Just don’t do it. There are situations where very clever engineering types get away with it, but don’t do it. The components attached to the pins will skew the clock and data signals, resulting in unpredictable programming. Additionally, if you ever want to use an in-circuit serial debugger, you can’t. Just don’t do it.

Tip #2 Threat level: Explosive
Always use a diode between the programming voltage and system voltage.
If using MCLR (master clear) on a PIC you must provide some voltage on the MCLR pin through a 10Kish resistor. This is also the pin to which you will apply ~13 volts to enter programming mode. I put a 1n4148 (equivalent) diode between the resistor and MCLR/Vpp pin (as shown in the schematic and rendering below). This keeps the programming voltage on the Vpp pin, preventing destruction of other components on your board.

Tip #3 Threat level: (re)tired
Low voltage programming is holding you back, man.
I have never been successful with LVP. I have never seen it work (consistently) with my own eyes. Just bite the bullet and spend $2.50 to build a JDM2 programmer.

 

Read more: Understanding ICSP for PIC Microcontrollers

Leave a Comment

Your email address will not be published. Required fields are marked *