Table of Contents
Hi-Pi high voltage PIC programmer
This is an out of circuit (not ICSP) high voltage PIC programmer for the Raspberry Pi.
Low voltage programming in-circuit is preferable but a high voltage programmer is sometimes a requirement for older parts which offer no low voltage mode, or to reset a device which has low voltage programming mode disabled in its configuration bits.
News
A bug may occur with this circuit in certain situations, please refer to the appendix.
Schematic
The circuit is a simple one and uses only a few components. The high voltage for programming is obtained using a part not designed for this purpose, however, it works perfectly well. This device is a TELCOM (Microchip) MOSFET driver with integrated voltage tripler.
The quad nand gate chip working here as a level converter is powered from 5V. A 74HC03 has been tested and works but a 74HCT03 should be used if available. The HC device has a typical input high level of around 2.6V which is adequate but the specification only guarantees a 3.5V level of operation.
A switch is used to switch in and out a 9V zener. With the switch off a 12V zener is active which is to support older generation PIC micros whereas 9V is needed for more modern ones. Read the programming data-sheet of your target device to determine the correct voltage. If in doubt, start at 9V and see if it works. If programming or erase fails, switch to 12V operation.
The TELCOM driver will produce something close to 15V on its output when activated, it's important to be careful with wiring here and appreciate that this is a dangerous voltage for something like a Raspberry Pi. Be careful when connecting the input pin.
Note: This is version 1 of Hi-Pi, version 2 will appear here later which will add some small improvements.
Pickle Microchip PIC ICSP
Using Pickle we will program a chip. Pickle can do ICSP but this is not an ICSP configuration here, this is purely for programming a PIC out of circuit.
Configuration
# RASPBERRY PI GPIO DEVICE=RPI BITRULES=0x001F SLEEP=1 # RASPBERRY PI GPIO (separate PGD DATA I/O) # = RPi HIGH VOLTAGE PROGRAMMER = # !MCLR/VPP VPP=26 # PGC CLOCK PGC=19 # PGD DATA_OUT PGDO=13 # PGD DATA_IN PGDI=6 # PGM PGM=-1
Example
Here we inspect a PIC18F2320. This chip is both high and low voltage compatible. By default low voltage mode is available, and for high voltage use ensure the PGM pin is pulled low. The low voltage mode can be disabled in the configuration bits, in this situation the PGM pin becomes a GPIO and can be left alone.
p16 i [000000] [PROGRAM] 1000 WORDS (0080 ROWS OF 0020 WORDS) [200000] [IDLOCATION1] FF . [200001] [IDLOCATION2] FF . [200002] [IDLOCATION3] FF . [200003] [IDLOCATION4] FF . [200004] [IDLOCATION5] FF . [200005] [IDLOCATION6] FF . [200006] [IDLOCATION7] FF . [200007] [IDLOCATION8] FF . [300000] [CONFIG1] CF00 [300002] [CONFIG2] 1F0F [300004] [CONFIG3] 8300 [300006] [CONFIG4] 0085 [300008] [CONFIG5] C00F [30000A] [CONFIG6] E00F [30000C] [CONFIG7] 400F [3FFFFE] [DEVICEID] 0504 DEV:028 REV:04 PIC18F2320 [F00000] [DATA] 0100 BYTES
We can program the chip using some test code.
First build the test.
hg clone http://hg.kewl.org/pub/pickles cd pickles/test make
Now program the hex file and inspect the chip once more.
p16 program pic18f2320.hex Total: 1324 p16 verify pic18f2320.hex Total: 1324 Fail: 0 p16 id [000000] [PROGRAM] 1000 WORDS (0080 ROWS OF 0020 WORDS) [200000] [IDLOCATION1] 01 . [200001] [IDLOCATION2] 02 . [200002] [IDLOCATION3] 03 . [200003] [IDLOCATION4] 04 . [200004] [IDLOCATION5] 05 . [200005] [IDLOCATION6] 06 . [200006] [IDLOCATION7] 07 . [200007] [IDLOCATION8] 08 . [300000] [CONFIG1] 0800 [300002] [CONFIG2] 1509 [300004] [CONFIG3] 8000 [300006] [CONFIG4] 0081 [300008] [CONFIG5] C00F [30000A] [CONFIG6] E00F [30000C] [CONFIG7] 400F [3FFFFE] [DEVICEID] 0504 DEV:028 REV:04 PIC18F2320 [F00000] [DATA] 0100 BYTES
Because this is an out of circuit programmer, we will now need to remove the chip from its programming station and place it in-circuit to operate.
Appendix
Thanks must go to Tomas Lorenc who has notified me a fix is required for devices which have MCLR configured as an I/O. In this situation a device is not brought out of reset and into programming mode due to VDD being raised first. Here he presents a fix for this situation.
For example, the PIC12F675 has this feature in it's configuration word.
bit5 MCLRE: GP3/MCLR Pin Function Select bit(5) 1 = GP3/MCLR pin function is MCLR 0 = GP3/MCLR pin function is digital I/O, MCLR internally tied to VDD