
If you followed my recent posts, you are probably aware of the UnIC project. This is a small FPGA-based board that fits into a 40-pin DIP socket and through some clever techniques can emulate almost any TTL or CMOS, 40-pin packaged device from the past. As a first real application, I’m making it into a replacement of the venerable Z80 processor since it has recently been discontinued.
The FPGA in question has built-in FLASH storage, but nevertheless: every FPGA needs programming. They commonly use JTAG for this purpose, even if only to download the FLASH content for subsequent boots. To make UnIC do anything, I needed a JTAG programmer.
There are many of these, in fact I have designed and built several in the past myself. Modern ones, at least modern ones with a reasonable price-tag, almost exclusively use some sort of USB interface chip from FTDI. Previously the FT2232D was in vogue, these days the much faster FT2232H is a favorite.
UnIC itself has two ways to gain physical access to the JTAG port of the FPGA: it has a 12-pin, 1.27mm pitch header and a flat (FPC) cable connector. The former has the problem that – when populated – interferes with the optional OLED screen. The good thing about this header configuration though is, I already have a programmer from the past that I could use. This also helped getting started quickly: I knew the programmer worked, I only needed to get UnIC going.
The other interface, the FPC one, has a number of connections. As I mentioned, it provides access to JTAG, but also to several otherwise unused FPGA pins. These pins are useful to add extra interfaces to a project, but they can also be very useful during bringup: one can expose internal logic signals that can elucidate the inner workings of the circuit, or be used as trigger sources for hard-to-identify events.
So, the idea for this project was: create a JTAG programmer to attach to this FPC interface.
The design process
While I’ve been toying with this idea for a long time, I have not started seriously consider it until I was ready to release Shadow Tracer to manufacturing. I thought, why not combine the two projects and save on shipping?
As I said, I have designed several similar JTAG programmers in the past, so I thought, it should be easy. I took one of my earlier designs and ported it over to KiCAD as a starting point. This porting was rather smooth as KiCAD already had a pretty competent importer for Altium projects. One trouble arose though: KiCAD mandates that all reference designators end with a number, something that I didn’t do in my Altium-based design. As a consequence KiCAD insisted on re-annotating the schematic losing all connection between the the schematic symbols and their associated footprints along the way. Not a huge deal in this case, but I fixed up KiCAD to be better about this. The change has been rather simple and hopefully be part of the next dot-release of the project. At any rate, it solved my immediate problems.
Then, I needed to change a few things:
- I changed the connector from a micro-USB to a USB-C one to go with the times.
- I changed the ESD diodes to something that’s easier to solder
- I replaced hard-to-work-with resistor packs with individual 0603 resistors.
- I updated almost all footprints to the equivalent ones from the standard KiCAD library.
- My old design used a MAX-V CPLD for level-shifting purposes (it is very cheap), but I didn’t want to deal with yet another JTAG programming project just to get my JTAG programmer off the ground. So I replaced that with a set of dedicated level shifters
- I replaced the target connector with the FPC one
- I added an extra connector to break out all FPC connector pins for easy probing
- I added test-points to some otherwise unused pins on the FTDI chip, the idea being that these could be used for extra control or status capture.
- I simplified the LDO design and – especially – the level shifter supply design.
The level shifters and the LDO need a little explanation: the FPGA in question on UnIC is a 3.3V I/O device, at least the way I have it hooked up. The FTDI chip can directly talk 3.3V. So, technically no level-shifter is needed. The problem though with the FTDI chips in general is that they ‘wiggle’ their pins during enumeration. This can confuse attached devices down-stream, such as my FPGA. To be safe, an isolator of sorts is needed. Luckily there is a pin exposed on the FTDI chip (they call it “power down”, but whatever) that can be used for controlling said isolators. If isolators are needed anyway, one might as well as use a level-shifter for the purpose. Now, the other design decision in the old project was to use a follower-regulator for the target-side power supply. This allowed for not loading down the target and also to support 5V targets with only 3.3V I/Os. None of this complexity is needed here: the target is fixed at 3.3V.
The main LDO I’ve used is an old – and strange – one. It has it’s heat-sink connection attached to its output, not to the more customary GND. I contemplated moving away from this chip, but decided against it in the last minute: I had some of these LDOs already in my drawer and in fact the VCC connection worked out better on the PCB: I had a VCC fill on the top layer anyway, so attaching to it was better then adding another (GND-connected) fill just for the purposes of the regulator.
As you can see the change list is actually rather extensive. Add the change in form-factor and you can see how a new PCB design was in store. Yes, the general idea and concepts didn’t change from the old design all that much, but that doesn’t help when footprints change.
A word from our sponsor
With all that though, I managed to finish the design in a day or so. It’s not a complex one and – as I have said – I am familiar with it. Off to PCBWay it went. They are sponsoring my work by offering free manufacturing services. The boards arrived very quickly and with the usual high manufacturing quality. In case you are looking for PCB services, check them out! Even if you don’t need a PCB, you should as they offer more than just PCB manufacturing: PCBA assembly, 3D printing, flex and rigid-flex PCBs, injection molding among other services. They truly are a one-stop shop for almost any manufacturing need.
The troubles start
My troubles started even before I had the PCBs in my hand: when ordering the parts, I realized that one of the level-shifters I’ve designed in was end-of-lifed by the manufacturer. Not a huge deal, Digikey still had a few in stock, but still poor form for a new design. I also haven’t been able to find a pin-compatible replacement, so if I was ever to build more than a couple of these a redesign is going to be needed.
When the PCBs and the components showed up, I could put the board together. The assembly was rather uneventful, my changing into more hand-assembly-friendly packages paid off. The only exception to this was the FPC connector: this was a major pain in the rear to work with.
I decided not to even attempt to use solder wire and opted for a very low-temperature solder paste. The benefit of this particular paste is that with its very low melting point it can be surgically applied and subsequently melted with a heat-gun without worrying about adjacent solder joints (done with a higher temperature solder) getting re-melted. This makes selective work and re-work much easier. A second benefit in this particular case is that I didn’t have to set the temperature of the gun to a point where it would melt the otherwise easily damaged plastic parts of the FPC connector. Still, with all that, the pads are tiny, they are almost completely underneath the connector and the tolerances are frightful.
The other problem was the LDO: when updating the packages, I’ve used an incorrect one: the actual part is smaller then the footprint. Thanks to the fill for the heat-sink, it can still be put in place, just had to scrape off some of the solder mask. Ugly, but functional.
Then, it was time to plug the contraption into a PC. And… nothing. I at the very least expected the FTDI chip to enumerate. But it didn’t. The troubleshooting in these instances follow a familiar pattern: check connectivity, check power, check clocks, check reset. Connectivity is easy to check, no issues there. Power? Not so great: the main 3.3V LDO is unstable. I said, it was an old design; I’ve used this regulator before:

I did change the way I used it in this design though. After checking the datasheet, I decided to get rid of the resistor in series with the output capacitor (R12): this was something I really didn’t like about it and it seemed the part actually doesn’t need it. In retrospect, it was a mistake. The LDO is not stable without it, and now – with the footprint removed – it’s a pain in the rear to hack it back in. Parallel is easy: it just needs to be bolted on top, but series is hard: you need an extra node on the board somehow. The result is really ugly:

But at least it worked and it stabilized the LDO. Yet, not improvements: still no enumeration. The core voltage – generated by an internal regulator in the FT2232H was rock solid, so I moved on to clocks. To my astonishment, there was no clock! Well, no wonder it won’t enumerate then. But why weren’t there any clocks? The clock circuit is simple to the point of being trivial:

Did I screw up the crystal selection? Nope. Did I screw up the capacitor selection? Yes, indeed, I did. Wrong values! Changing them to the right ones (luckily I had them) didn’t change the behavior. However, I did notice that during power-up, the oscillator briefly comes to life, but then shuts down again. This indicates some signs of life, in fact it indicates that something shuts the oscillator down. This is new, I haven’t seen this before from any of the FTDI chips I’ve worked with.
So what gives? Is there something shorted? Does the core get into some over-current condition? Is it that the core voltage drops too low and browns out the controller? Or same for the I/O? No, no, no, no and no. None of these seemed to be happening. In desperation, I started de-soldering components that weren’t crucial to enumeration: the level shifters, the EEPROM, pull-ups and downs; nothing.
As a last resort, I removed the ESD diode from the USB wires:

After that, finally, the USB connection come up and my PC enumerated the FTDI part. So, it was the ESD diode. But why?! I didn’t have it in backwards. It is 5V rated and it seemed not to impede the D+ and D- lines going up and down. It’s quite possible that it has too much capacitance (320pF) for a high-speed USB 2.0 connection. Maybe. I didn’t investigate too hard. I was too tired of this hunt. Off the board it went I moved on with the bring-up.
More troubles
Now with the FTDI chip enumerating, I could concentrate on the target side of things.
Something I realized even before the boards came back was the lack of de-coupling capacitors on the target-side voltage domain of the level shifters. It wasn’t terribly hard to add them, but they had to go on the back-side of the PCB: that was where the right traces were exposed in convenient locations.

I connected the target over the thin FPC and… again, nothing. I couldn’t even read the ID from the FPGA. Back to hunting problems, I relatively quickly zeroed in on the FPC connector. This is not something that’s terribly easy to ‘beep’ out; the connections are very tight. The aforementioned break-out helped on one side and plugging and actual FPC with the other end exposed helped on the other. It turned out the terminals had a number of shorts. These must have been under the connector as they were not visible form the outside. I removed the connector and tried a new one (without applying any more solder paste this time). Now, all the shorts were gone, which was great news. They were replaced by a number of opens, which was not. Frenetic soldering iron action ensued. Ungodly amounts of flux later I eventually got all the connections working. I certainly wasn’t amused and not looking forward for a repeat experience.
Conclusions
Eventually I did get the board working. It is still a good citizen of my ever-spreading setup for UnIC development work:

In that sense the project was an (eventual) success. I would not call it model to follow by any means though. It was plagued by several design flaws, mistakes and rushed decisions that all came back to bite me later on. I’m not proud of this project and I post it as a cautionary tale rather then a boast: don’t follow my footsteps; check your work prior to sending it to manufacturing and always, always be on the lookout for ‘just a small change’. Those are the easiest to get wrong. Five of the nine changes I listed at the top resulted in problems I needed to deal with in one form or another.