In-circuit serial programming

From Wikipedia, the free encyclopedia
Jump to: navigation, search

In-Circuit Serial Programming (ICSP) is a protocol for programming microcontroller devices such as PIC microcontrollers, AVRs, and the Parallax Propeller. ICSP has been primarily implemented by Microchip Technology for programming PIC and dsPIC devices.

ICSP programming is performed using two pins, clock (PGC) and data (PGD), while a high voltage (12V) is present on the Vpp/MCLR pin. Low voltage programming (5V or 3.3V) dispenses with the high voltage, but reserves exclusive use of an I/O pin.

Microchip ICSP[edit]

Microchip PICkit ICSP programmer

Microcontrollers are typically soldered directly to a printed circuit board and usually do not have the circuitry or space for a large external programming cable to another computer. A separate piece of hardware, called a programmer is required to connect to an I/O port of a PC on one side and to the PIC on the other side. A list of the features for each major programming type are:

  1. Parallel port - large bulky cable, most computers have only one port and it may be inconvenient to swap the programming cable with an attached printer. Most laptops newer than 2010 do not support this port. Parallel port programming is very fast.
  2. Serial port (COM port) - At one time the most popular method. Serial ports usually lack adequate circuit programming supply voltage. Most computers and laptops newer than 2010 lack support for this port.
  3. Socket (in or out of circuit) - the CPU must be either removed from circuit board, or a clamp must be attached to the chip making access an issue.
  4. USB cable - Small and light weight, has support for voltage source and most computers have extra ports available. The distance between the circuit to be programmed and the computer is limited by the length of USB cable - it must usually be less than 180 cm. This can make programming devices deep in machinery or cabinets a problem.

ICSP programmers have many advantages, with size, computer port availability, and power source being major features. Due to variations in the interconnect scheme and the target circuit surrounding a micro-controller, there is no programmer that works with all possible target circuits or interconnects. Microchip provides a detailed ICSP programming guide[1] Many sites provide programming and circuit examples.

PICs are programmed using five signals (a sixth pin 'aux' is provided but not used). The data is transferred using a two wire synchronous serial scheme, three more wires provide programming and chip power. The clock signal is always controlled by the programmer.

Typical programming communication

Signals and pinout[edit]

Pic icsp.jpg
Typical chip connections
  • Vpp - Programming mode voltage. This must be connected to the MCLR pin, or the Vpp pin of the optional ICSP port available on some large-pincount PICs. To put the PIC into programming mode, this line must be in a specified range that varies from PIC to PIC. For 5 V PICs, this is always some amount above Vdd, and can be as high as 13.5 V. The 3.3 V only PICs like the 18FJ, 24H, and 33F series use a special signature to enter programming mode and Vpp is a digital signal that is either at ground or Vdd. There is no one Vpp voltage that is within the valid Vpp range of all PICs. In fact, the minimum required Vpp level for some PICs can damage other PICs.
  • Vdd - This is the positive power input to the PIC. Some programmers require this to be provided by the circuit (circuit must be at least partially powered up), some programmers expect to drive this line themselves and require the circuit to be off, while others can be configured either way (like the Microchip ICD2). The Embed Inc programmers expect to drive the Vdd line themselves and require the target circuit to be off during programming.
  • Vss - Negative power input to the PIC and the zero volts reference for the remaining signals. Voltages of the other signals are implicitly with respect to Vss.
  • ICSPCLK - Clock line of the serial data interface. This line swings from GND to Vdd and is always driven by the programmer. Data is transferred on the falling edge.
  • ICSPDAT - Serial data line. The serial interface is bi-directional, so this line can be driven by either the programmer or the PIC depending on the current operation. In either case this line swings from GND to Vdd. A bit is transferred on the falling edge of PGC.

RJ11 pinout[edit]

RJ11 to ICSP PIC programmer

An industry standard for using RJ11 sockets with an ICSP programmer is supported by Microchip. The illustration below represents information provided in their data sheets. However, there is area for confusion. The PIC data sheets show an inverted socket and do not provide a pictorial view of pinouts so it is unclear what side of the socket Pin 1 is located on. The illustration provided here is untested but uses the phone industry standard pinout (The RJ11 plug/socket was original developed for wired desktop phones).


See also[edit]