PIC programming with FT232 & Pickle

This Forum is about the Opentherm gateway (OTGW) from Schelte

Moderator: hvxl

Post Reply
lentinj
Starting Member
Starting Member
Posts: 2
Joined: Wed Feb 03, 2021 11:15 pm

PIC programming with FT232 & Pickle

Post by lentinj »

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:

Code: Select all

FTDI -> 16F88
---------------
VCC -> VDD/14
GND -> VSS/5
TxD -> !MCLR/4
DTR -> PGC/12
RxD -> PGD/13
CTS -> PGM/9
3) Add 2 10k pull-up/down resistors between the following:

Code: Select all

FTDI -> 16F88
---------------
VCC -> !MCLR/4
GND -> PGM/9
4) Download pickle from the website and build with "make linux". Create a ".pickle" file in your home directory containing:

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
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:

Code: Select all

./src/p14 id
./src/p14 program gateway.hex
./src/p14 verify gateway.hex
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.
Last edited by lentinj on Sun Feb 07, 2021 1:39 am, edited 1 time in total.
hvxl
Senior Member
Senior Member
Posts: 1965
Joined: Sat Jun 05, 2010 11:59 am
Contact:

Re: PIC programming with FT232 & Pickle

Post by hvxl »

Very interesting.

Instead of manually editing the hex file, you can take the sources and compile them after defining the LVP preprocessor macro. Not only will that produce the correct config words, it will also make the LA command unavailable. Maybe it should also affect the PR=L output; make it "L=-XOMPC". Or even: "L=-FXMPC", because the flame is probably more interesting than the override state. Although I would have to check if using a "-" doesn't cause problems somewhere else.
Schelte
lentinj
Starting Member
Starting Member
Posts: 2
Joined: Wed Feb 03, 2021 11:15 pm

Re: PIC programming with FT232 & Pickle

Post by lentinj »

hvxl wrote:Instead of manually editing the hex file, you can take the sources and compile them after defining the LVP preprocessor macro.
Thanks, that's certainly a lot cleaner :)

I've also tried an upgrade via. otmonitor, and this also seems to work fine, with the PIC still configured for LVP. This may not be a surprise, but I thought it worth checking.
Post Reply

Return to “Opentherm Gateway Forum”