Subsections

11 Hardware


18. Faster and cheaper PIC programming: ICSP

Last updated:

$Date: 2003/01/18 18:33:38 $

Some Microchip PIC micro-controllers are programmable once soldered on the application board. This technique, known as ICSP (In-Circuit Serial Programming), has been implemented by Microchip to allow industrial users to program the controller at the very last moment before shipping, thus limiting the number of parts to store (unprogrammed, programmed, on board) and increase flexibility on the assembly line (different software versions per country, special customer tailored versions, evolutions of stocked boards).

For the hobbyist, the advantage on the hardware side is that the programming device is dramatically simplified, and that costly ZIF (Zero Insertion Force) supports, up to 40 pins for some PIC, aren't needed anymore. For the software developer this results in fewer physical manipulations, fastening the code/load/test cycle.

The constraint is that during programming, the PIC must be isolated from the application board regarding power pins (Vcc and gnd), and that one must have access to 2 pins having an alternate use: 2 I/O pins then become programming clock and serial data. Furthermore, the reset pin receive the Vpp programming voltage.

In order to isolate the PIC at programming time on the application board, one can use relays, or jumpers, or may use a dual line of pins connector (18.1). The drawback of a relay is not only its cost but also its size. Jumpers manipulation is tedious and error prone. Whereas the pro of the connector system is a risk-less use and low real-estate consumption on the board.

On this site (http://www.iki.fi/hyvatti/pic/picprog.html) one can see an unusual use of this technique, in the sense that it's not used to program PIC on application board, but rather to do a dedicated programmer board still usable with all PIC supporting ICSP (pins used for alternate functions are not the same from a Microchip family to another). Nevertheless, the electronic used to link the serial port of a PC to the PIC is mature, cheap, and perform very well.

Figure 18.1: ICSP programming connector
\begin{figure}\centering\epsfig{file=graphics/icsp_connector.eps, height=12.7cm}\end{figure}


This is the circuit that we use, redrawn to be be adapted to a 10 points in 2 rows connector (figure 18.1), ending in a very compact and simple ICSP programming system: You can see some pictures in part IV.

There can't be no forgetting of a strap or commutating mistake. For the software used with this programming device, see chapter 14.


19. Serial/I2C Interface

19.1 Hardware

19.1.1 Presentation

This module is intended to allow the use of the I2C bus from the serial port of a standard PC or from an other computer or controller fitted with a serial port using RS232 specifications. It can also be used to visualize the operation of an I2C bus by the way of a monitoring PC (connected to the serial port) or by the embedded control circuitry.

The module contain two parts :

19.1.2 How does it work

The circuit is build around the PCF8574 (Philips semiconductors) which is a specialized component normally used to provide a 8 bits wide bidirectional extension for microcontrollers. This circuit is available under two ordering numbers , PCF8574 and PCF8574A. The difference between them is the base address which increase flexibility in the use of the bus.

Since the PCF8574 is +5volts powered, and the serial port of a PC has +/- 12volts levels in accordance with the RS232 specifications, a level translator is needed between them. It is provided by a MAX232 (Maxim semiconductors) which is used here in his most typical application circuit from the Maxim application handbook. The six inverters circuit 74LS06 provide bidirectional communications between the bufferized serial port (4 wires) and the I2C bus (2wires).

Figure 19.1: I2C Interface
\begin{figure}\centering\epsfig{file=graphics/i2c-1.eps, height=20cm}\end{figure}
Figure 19.2: I2C Interface
\begin{figure}\centering\epsfig{file=graphics/i2c-2.eps, height=10cm}\end{figure}
Figure 19.3: I2C Interface
\begin{figure}\centering\epsfig{file=graphics/i2c-3.eps, height=10cm}\end{figure}
Figure 19.4: Pin configuration PCF8574
\begin{figure}\centering\epsfig{file=graphics/pin-PCF8574.eps, height=5cm}\end{figure}
Pin configuration
SYMBOL PIN DESCRIPTION
A0 1 address input 0
A1 2 address input 1
A2 3 address input 2
P0 4 quasi-bidirectional I/O 0
P1 5 quasi-bidirectional I/O 1
P2 6 quasi-bidirectional I/O 2
P3 7 quasi-bidirectional I/O 3
Vss 8 supply ground
P4 9 quasi-bidirectional I/O 4
P5 10 quasi-bidirectional I/O 5
P6 11 quasi-bidirectional I/O 6
P7 12 quasi-bidirectional I/O 7
$ \overline{INT} $ 13 interrupt output (active LOW)
SCL 14 serial clock line
SDA 15 serial data line
Vdd 16 supply voltage

19.2 software

Here (http://botzilla.free.fr/hard/appli.tgz), there is a simple application to use this Serial / I2C Interface on a PC (Linux or Windows9x).

There is a Makefile with these files, to compile this program (Linux) type:

make

Because, it's not a real driver (use of ioperm), you have to be root (for Linux user) to use it. This program will test COM1 and COM2 port, and look for a valid PCF target (scan all possible address). When a valid target is found, the program send some bytes to switch ON or OFF the 4 leds connected on the PCF.

botzilla@free.fr , http://botzilla.free.fr/