PIC programming with FT232 & Pickle
Posted: Wed Feb 03, 2021 11:57 pm
I was too cheap to buy a PIC programmer which I'd likely never use again, and https://wiki.kewl.org/dokuwiki/projects:pickle suggests it's capable of low-voltage programming with an FT232 USB serial adapter which I already have plenty of.
Admittedly I'm yet to try my OTGW with the boiler/thermostat (I've been told to wait until spring before tinkering), but all appears to work otherwise. So thought I'd write up the process here if it's useful.
1) Switch the FT232 to 5v mode (on my red ones there's a jumper near the serial pins)
2) Set up the 16F88 and a FT232 adapter onto a breadboard, making the following connections with jumper wires:
3) Add 2 10k pull-up/down resistors between the following:
4) Download pickle from the website and build with "make linux". Create a ".pickle" file in your home directory containing:
5) Get a gateway.hex image, open with a text editor and change ":02400E00742F0D" to ":02400E00F42F8D" [EDIT: Fix checksum byte]
What this does is change the PIC configuration the HEX file sets to Low-voltage-programming. Because we're using LVP the PIC won't let us set it to HVP, and the write will fail otherwise.
6) Write the new .hex file:
7) Put the PIC into your OTGW. Connect LEDS5 pin to GND (e.g. the outer RST pin) with a 10k resistor.
Because we used LVP, we need to connect PGM to GND before the PIC will boot. This means we lose out on a LED, but I'm putting this in a cupboard anyway.
Admittedly I'm yet to try my OTGW with the boiler/thermostat (I've been told to wait until spring before tinkering), but all appears to work otherwise. So thought I'd write up the process here if it's useful.
1) Switch the FT232 to 5v mode (on my red ones there's a jumper near the serial pins)
2) Set up the 16F88 and a FT232 adapter onto a breadboard, making the following connections with jumper wires:
Code: Select all
FTDI -> 16F88
---------------
VCC -> VDD/14
GND -> VSS/5
TxD -> !MCLR/4
DTR -> PGC/12
RxD -> PGD/13
CTS -> PGM/9
Code: Select all
FTDI -> 16F88
---------------
VCC -> !MCLR/4
GND -> PGM/9
Code: Select all
# 0 TXD / 1 RXD / 2 RTS / 3 CTS
# 4 DTR / 5 DSR
# 6 DCD / 7 RI
DEVICE=FTDI
IFACE=0
BITRULES=0x1000
SLEEP=0
VPP=0
PGC=4
PGD=1
PGM=3
What this does is change the PIC configuration the HEX file sets to Low-voltage-programming. Because we're using LVP the PIC won't let us set it to HVP, and the write will fail otherwise.
6) Write the new .hex file:
Code: Select all
./src/p14 id
./src/p14 program gateway.hex
./src/p14 verify gateway.hex
Because we used LVP, we need to connect PGM to GND before the PIC will boot. This means we lose out on a LED, but I'm putting this in a cupboard anyway.