SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By Piquan
#200534
I came across a recent surprising discovery: the Pocket AVR Programmer (https://www.sparkfun.com/products/9825) doesn't seem to be safe for use with 3.3V devices. As I understand it, on other USBtinyISP-based programmers, the output buffer exists to allow 3.3V safety, but that doesn't seem to be the case here. I think this was because it uses a 74AC125 instead of a 74AHC125, so voltage from the CTL pin is going through the protection diodes to the ISP cable's Vcc; the AHC series doesn't have protection diodes, so can do level-shifting. Is there something I overlooked?

The most obvious indication is that, in "No Power" mode (which is supposed to decouple the ISP cable's power from USB), the board still receives power through the ISP header; it will fully power (at 8mA) my "flash an LED with an ATtiny84" test.

In the "Power Target" switch position, the ISP header's Vcc pin is connected to the USB power; in the "No Power" mode, it isn't. In either case, the output buffer gets its Vcc pin from the ISP header's Vcc pin. I think that the idea is, if the device has its own power supply, that will be used to supply power to the buffer, so the buffer's output is at (for instance) 3.3V if you have a 3.3V board.

But the 74AC125 doesn't seem to be a suitable output buffer for level-shifting operations (see below for why). For instance, the maximum ratings restricts Vi to -0.5≤Vi≤Vcc+0.5. For contrast, note that the 74AHC125 https://www.diodes.com/assets/Datasheets/74AHC125.pdf restricts Vi to -0.5≤Vi≤7.0, regardless of Vcc, and the datasheet specifically notes that it's suitable for level-shifting. If you connect the programmer to a 3.3V board (with the switch in the "No Power" position), the 74ACT125D will have its Vcc at 3.3V, but the ATtiny2313 will be feeding it a 5V signal, which is outside the buffer's spec. This causes real problems through the protection diodes, but first let me talk about another component.

A confounding factor is the 22k resistor between TARGET-PWR and CTL, labeled R10 in the schematic at https://www.sparkfun.com/datasheets/Pro ... er-v15.pdf. The CTL line is connected from the ATtiny2313 to the (active-low) output-enable lines on the 74AC125, so I'm guessing that CTL is used to tri-state the buffer when it's not in programming mode. I note in the firmware at https://github.com/sparkfun/Pocket_AVR_ ... spi/main.c that CTL is always set as output (see where DDRD is set). (It's managed by the USBTINY_POWERUP and USBTINY_POWERDOWN commands.)

That resistor seems to be designed to make sure that the output buffer's Vcc is never left floating: it's driven to USB power when the ISP is idle or when it's in "Power Target" mode, and is brought to ground if the ISP is in "No Power" mode but not connected to the board, so that the buffer's MISO line isn't ever enabled yet floating (for instance, if the target isn't connected properly).

But the problematic voltage doesn't come through that 22k resistor R10; that's <1mA, so the device's . But the CTL pin is going to the four output enable pins on the 74AC125, and that's where there's a problem. Those pins have built-in protection diodes built in to ensure that they're never driven above Vcc. But now CTL is driving the pins at 5V, and Vcc is only 3.3V, so those protection diodes start conducting. The result is that the Vcc line of the 74AC125, and hence of the ISP header, is driven up to almost 5V!

The MC74AC125 on the board I got lists an input diode current rating of 20mA (the usual for 74ACxx-series diode currents), but I wouldn't want to press my luck with a mixed-voltage system.

I haven't tested a 74AHC125 on this board, but it seems to be the right replacement for making this 3.3V safe. For more details, see section 4.1 "Level Matching and Conversion" in TI's "AHC/AHCT Designer’s Guide" http://www.ti.com/lit/ug/scla013d/scla013d.pdf. Compare this to the typical 74Cxx or 74ACxx CMOS input shown in section 2.1.2 of "Designing With Logic" http://www.ti.com/lit/an/sdya009c/sdya009c.pdf.
(Using AHC is perfectly fine for most pins. Coupling the MISO output of a 3.3V 74AHC125 to the 5V ATtiny2313 is a bit close on the voltage levels, but should be fine in practice. R10 makes that tricky; during programming, the buffer's Vcc will be pulled down a little bit depending on the ISP cable's impedance, so it may be a good idea to consider whether or not it's still necessary if the design is changed to the AHC family.)

Is there something I've overlooked? I'm thinking about replacing the 74AC125 with a 74AHC125, and cutting out R10, so I can use this with a 3.3V board. But I want to make sure I've got my information straight before I do so. Any thoughts?