Summary of Microcontroller In Circuit Serial Programming (ICSP) with Microchip PIC
This article explains In-Circuit Serial Programming (ICSP), a method for programming Microchip PIC or Atmel AVR microcontrollers directly on the circuit board. ICSP offers benefits like shortened development cycles, in-field firmware upgrades, system calibration, and unique product ID assignment. The technique uses programming clock (PGC/ICSPCLK), data (PGD/ICSPDAT), and MCLR/VPP pins. Design considerations include using dedicated pins for ICSP, isolating VPP with a Schottky diode and resistor or capacitor, and isolating clock and data lines with resistors. Proper header placement near the chip is also advised for signal integrity.
Parts used in the In-Circuit Serial Programming project:
- Microchip PIC or Atmel AVR microcontroller
- Schottky diode
- Resistor (1k to 10k ohms)
- Capacitor (for R/C isolation)
- ICSP header connector
In Circuit Serial Programming is a method of directly programming a Microchip PIC or Atmel AVR while in they are connected to a circuit, as opposed to programming the chip ahead, and only then soldering it to a circuit. There are many benefits to ICSP, but also some important design considerations which I will try to highlight.
In circuit programming has many advantages:
- It shortens the development cycle – it is really annoying to take a chip out of the board each time it needs to be reprogrammed, and it’s even much harder with SMD.
- Allows customer and in field firmware upgrades
- Calibrate the system during manufacturing or in the field
- Assign unique ID \ serial number to product
How to prepare your circuit to work with ICSP?
The programmer uses serial signaling scheme to program the chip in circuit. The signaling is carried through the programming clock (PGC or ICSPCLK) and the programming data (PGD or ICSPDAT) pins. In addition, the MCLR/VPP pin is used as either a high voltage programming signal or an attention indicator to the device.
Wherever application allows, use dedicated pins for ICSP. It will save you much trouble. Not sharing a pin both for ICSP and I/O for example, minimizes the preparation work which needs to be done to allow ICSP.
Often, and especially true with low pin devices, it is not possible to dedicate the 3 needed pins just for ICSP, and when want them to have dual functionality.
In this case:
1. Isolate Vpp from the circuit by using a Schotkey diode and an R/C. NOTE: in some devices, like the PIC12F629, this pin will be driven to about 13 volts by the programmer while programming the device. Make sure whatever is connected to the Vpp pin can sustain this voltage level, or isolate it with an appropriate resistor or a Schotkey diode.
2. Isolate ICSP_Clock and ICSP_Data from the rest of the circuit. The isolation method is application specific, which unfortunately means there is no ready recipe. Often, a resistive isolation works fine. Recommended resistor values are 1k to 10k.
3. Physically locate the ICSP header as close as possible to the programmed chip, to reduce attenuation.
Common Microchip PIC ICSP layouts
Additional reading and references
- Microchip PICKit 2 manual
- Microchip In-Circuit Serial Programming™ (ICSP™ ) Guide
- ICSP in wikipedia
For more detail: Microcontroller In Circuit Serial Programming (ICSP) with Microchip PIC