Last year, I acquired my first VIC-20 and when I discovered that someone shared the Gerber files for a fairly recent version of the Final Expansion 3 (english) for that machine on Github, I decided to set out and build one of those, of course. The FE3 might be a story for a later post, though. Because in order to build that cartridge, I first had to find an affordable way to program the ATF1504 CPLD that is used here.
The ATF1504 has a JTAG interface and that was the obvious choice for the task. I had a CJMCU (?) FT232HQ breakout board (from eBay) lying around that I had used before together with OpenOCD to successfully program the Xlinix CPLDs used in the replacement PLA.
First though, I had to convert the JED file for the CPLD into a SVF file that I could then play over the JTAG interface. After some research, more trial-and-error and a little help from the folks at Forum64, I learned that this could be done using the ATMISP tool provided by Atmel.
Next, I whipped up a temporary adapter on a breadboard and tried to write the resulting SVF file to the CPLD using different players — with no success. After some time spent debugging my setup, I ordered additional ATF1504 ICs from a more reliable source. With these, I was finally able to program the CPLD using OpenOCD:
bin-x64\openocd.exe -f scripts\interface\ftdi\um232h.cfg -c "adapter_khz 400" -c "transport select jtag" -c "jtag newtap ATF1504AS tap -irlen 3 -expected-id 0x0150403f" -c init -c "svf VC20FINAL-V3-2.svf" -c "sleep 200" -c shutdown
It turned out that the devices from the first batch that I received weren’t quite as new as the seller had claimed. They had been used before and probably programmed in a way that disabled the JTAG interface. Luckily, I received another reply on Forum64 hinting at a way to bring those ICs back to life.
Though (almost) not documented in the datasheet, the OE1 pin of the ATF1504 doubles as Vpp. According to the author of the post, applying 12V to that PIN through a current limiting resistor would reset the JTAG functionality. So I added a 12V power supply to the breadboard contraption and created another SVF file to erase the CPLD, again using ATMISP. And indeed, with 12V on OE1 I was able to erase the used ATF1504!
bin-x64\openocd.exe -f scripts\interface\ftdi\um232h.cfg -c "adapter_khz 400" -c "transport select jtag" -c "jtag newtap ATF1504AS tap -irlen 3 -expected-id 0x0150403f" -c init -c "svf atf1504as-erase.svf" -c "sleep 200" -c shutdown
In order to be able to reproduce all of this later more easily, I decided to write this blog post and I moved on to create a custom PCB that would replace the breadboard adapter and plug as a “hat” onto the FTDI board.
I had to wait quite a while for the last components to arrive, but then I was able to successfully assemble and test the ATF1504-FT232HQ Shield. It features a MAX662 boost converter to produce the 12V programming voltage on-board.