In-circuit serial programming
|This article does not cite any references or sources. (February 2013)|
||It has been suggested that this article be merged into In-system programming. (Discuss) Proposed since December 2011.|
Microchip PIC ICSP family of chips
Micro-controllers 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. The type of programmer, how it connects to the PC, and the various advantages and disadvantages of each are not within the scope of this document. However, a short list of the features for each major programming type is given here.
- 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.
- 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.
- 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.
- 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 at ww1.microchip.com/downloads/en/devicedoc/30277d.pdf 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.
ICSP signals and pinout
- 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.
Microchip PIC ICSP programmer to RJ11 pinout
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).