Erasing and Programming the ATF1504 CPLD

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 CPLDs turned out not to be not as “new” as the seller claimed.

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.

Using ATMISP to create the SVF file.

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.

The initial JTAG adapter contraption.

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.

External 12V on the breadboard adapter.

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.

Schematics of the ATF1504-FT232HQ shield.

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.

Revision 1 of the ATF1504-FT232HQ shield.

As usual, the project files for the adapter board are available on Github. Finally, a big thanks to the ever helpful crowd on Forum64 who guided me along the way!

 

10 thoughts on “Erasing and Programming the ATF1504 CPLD

  1. Hi,
    bei microchip ist ATMISP nicht mehr zu finden … kannst du das tool auf github hochladen? danke!

  2. Thank you for your project
    Can you give your version of openocd. With the last version (OpenOCD 0.10.0 ), I don’t have the same syntax and it’s not working
    Thanks

  3. I have encountered the same problem when I try to program a ATF1502, I have used Altera USB Blaster and UrJtag. After connecting OE1 to 12 volt the chip back to life! I’m be able to program only 1 chip of 2, one not respond at all even if I use the above trick, anyway thank for the help!

  4. This works great, it took some hours to figure it all out but now it works great!
    thank you for releasing this project for free for people to use, helped me alot and salvaged 18 ATF1502AS that i could not program before! (cheap aliexpress :p)

  5. What type of capacitor are you using for C7 and C8. Seems to be a KEMET one. If I open the KiCAD file it says it should be a SMD 1206 (3216 metric). But I couldn’t find one at the usual suppliers.

  6. Looking at the schematics again now, I noticed a typing error: both C7 and C8 should have 4.7uF as described in the datasheet for the MAX662A. Maybe, this is already what you were struggling with. I used polarized tantalum caps but I can’t tell anymore where I got them from. They should be easy enough to find though, e.g. part no. “T491B 4,7U 20” at Reichelt.

  7. I’ve tried to program my svf file to the ATF1504AS. I get the following message:
    Open On-Chip Debugger 0.11.0 (2021-03-07-12:52)
    Licensed under GNU GPL v2
    For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
    adapter speed: 400 kHz

    jtag
    Info : clock speed 400 kHz
    Info : JTAG tap: ATF1504AS.tap tap/device found: 0x0150403f (mfg: 0x01f (Atmel), part: 0x1504, ver: 0x0)
    Warn : gdb services need one or more targets defined
    svf processing file: “Z80_512K.svf”

    Time used: 0m0s0ms
    svf file programmed successfully for 0 commands with 0 errors

    shutdown command invoked

    What does the warning mean. Is the CPLD programmed? I cannot find any target definitions for the ATF1504AS within OPENOCD.

  8. I am not exactly sure what the warning means, but I’m also getting it and it does not matter for our simple flashing purposes. The rest of the output you are getting from OpenOCD looks good, too. Except for the part saying “0 commands with 0 errors”, which probably means that your CPLD has not been programmed.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.