The algorithm used to program the target PIC is derived from the algorithm published by Microchip. The steps used to program each individual word onto the target PIC are:
- Advance to the address where the word belongs.
- Read the word already at the address.
This step is not part of Microchip's published algorithm.
- If the word at the address is different than the word to be programmed:
- Write the word to the target PIC.
- Read the word back from the target PIC.
- If the word read back is not the word to be programmed:
- Stop; a verify error has occurred.
- Continue with the next word.
Variable voltage power supply
In order to provide production quality programming support, a variable voltage power supply is required for the target PIC. The power supply is used to change the target PIC's voltage to its minimum and maximum operating ranges. The program on the target PIC is verified at both extremes of the operating voltage range. The programmer needs the variable voltage power supply only for production quality programming; it is not needed for the programmer to function.
Software voltage selection
The programmer selects the supply voltage by use of a DAC. I selected the MAX522 8-bit DAC for its simple synchronous serial interface. The MAX522 provides an analog voltage that is amplified before being supplied to the target PIC. It cannot be used to power the target PIC directly because it can only source 5ma and the target PIC requires 10ma during programming.
To accommodate a wider range of supply voltages and source enough current to operate the target PIC during programming, a voltage amplifier is included in the design. I selected the 1458 standard dual op amp to make use of both its op amp circuits and its low price. The voltage output of the MAX522 is input to one op amp circuit configured as an inverting amplifier with unity gain. The output is feed into the second op amp circuit which is configured as an inverting amplifier with a gain of -2. Inverting amplifiers are used to minimize noise in the in the voltage amplifier and the output to the target PIC.
Negative and double voltage power supply
The 1458 op amp requires a power supply at least as wide as its intended voltage output. In the voltage amplifier design, the first inverter can output down to -5 volts, and the second can output up to 10 volts. This makes the programmer's 5 volt power supply inadequate to power the voltage amplifier. I chose to use a standard 7660 switched capacitor voltage converter to supply the op amp with power. The 7660 is used to provide both an inverted voltage, -5 volts, and a doubled voltage, 10 volts, from the programmer's 5 volt power supply.