Close
0%
0%

FTDI-be-gone TTL to UPDI programming adapter

Use the FTDI-be-gone USB UART for UPDI programming

Similar projects worth following
381 views
0 followers
UPDI is a new(er) programming protocol for Microchip embedded controllers. It's a further outgrowth of the trend of programming protocols to be effectively bidirectional asynchronous serial. The forerunners to UPDI were PDI and TPI, which are both very similar, but clocked. UPDI is completely asynchronous. So whereas PDI and TPI could be "faked" with an SPI port (by adding otherwise spurious start and stop bits) UPDI can be simply done with a TTL UART and a resistor between TX and the UPDI data pin (to allow the chip priority to drive the line).

But there is (always) an extra wrinkle. If you want to use the UPDI / !RESET pin as an added I/O pin then you have to start UPDI programming with a 12 volt pulse - just like TPI.

This project is a USB UART adapter circuit intended to use the DTR transition when the port is opened to generate a roughly 500 µs 12 volt pulse on the UPDI pin, followed by connecting TX and RX of the UART up to the chip for UPDI.

This project is somewhat similar to the TPI adapter project. The big difference is that the functions that were on 3 pins for TPI are crammed here into a single pin.

The boost converter to take the input power and convert it to 12 volts is unchanged. However, it is gated onto the UPDI pin this time with a MOSFET that is itself triggered by an RC edge detector. DTE dropping low (which happens when the serial port is opened) will cause the MOSFET gate to be pulled low for about 500 µs, pulsing the pin to +12. After that the TX line is bridged to UPDI by a 1 kΩ resistor. The resistor both protects the TX pin from the 12 volt pulse and insures that the chip is permitted to override the programmer when it wants to speak (as there's no easy way to tri-state the TX pin). On the RX side, we do have to protect the UART from the 12 volt pulse, and that's easily done with with a smaller resistor and a Schottky diode to Vcc (one could argue that the diode is unnecessary as the UART itself almost certainly has the same protection diodes internally, but it's best to be safe).

On the input side, you need 5 pins - Vcc (either +5 or +3.3 volts), ground, TXD, RXD and !DTR. I've chosen to use a 10 pin connector that's pin-compatible with my FTDI-be-gone TTL variant. I'm going to build it with a female connector mounted on the bottom of the board so that it just sort of stacks on top, much like the TPI adapter can stack on top of a USB µISP.

UPDI adapter.pdf

Adobe Portable Document Format - 18.16 kB - 07/13/2023 at 18:45

Preview

  • Another possible way to go

    Nick Sayer07/14/2023 at 22:31 0 comments

    I've been reading the datasheet for the ATTiny3226 and one thing it notes in the reset/UPDI fuse section is that if you configure PA0 as a GPIO, then one issue you face is that if it's set up as an output and is driving, then there's no way to sense the 12 volt UPDI pulse. The workaround for that is that the output driver is disabled for a short period immediately after RESET.

    So it's possible that in order to absolutely wrest control of the chip to the UPDI interface, you may need a sequence of powering the chip off briefly, then pausing for a few milliseconds, then triggering the 12 volt pulse.

    Doing this probably requires some intelligence. But it'd certainly be within the capabilities of an ATTiny9. It could camp out on !DTR waiting for a negative going pulse, then it would turn off a P MOSFET gating power to the UPDI interface for a few ms, then turn the power back on and trigger the 12 volt pulse a few ms later.

    One issue with this idea is that when you turn the power off, you also need to disconnect the UPDI pin itself, lest it wind up powering the chip when Vcc is off. You can use a P MOSFET to do this despite UPDI being a bidirectional pin. You wire the MOSFET so that the body diode is reverse-biased in the direction you want to not allow current flow when it's switched off (so the drain is to the device and the source is to the programmer). When the gate is pulled low, the MOSFET will conduct in either direction.

    So you wind up using 3 P MOSFETs. One controls the imposition of 12 volts onto the UDPI pin, one turns Vcc off and on and has a common gate with the one that disconnects UPDI from the programmer.

    The only remaining trick is that the 12 volt MOSFET's gate has to be controlled carefully. You can't use high or low signals from the T9 to turn it on and off because the source is at 12 volts. A high output from the T9 is going to be 7 volts lower than that. The solution is to use tri-state logic - set the pin as an input (and add a pull-up resistor from the source pin) to turn the MOSFET off and set the pin as an output and write a "1" (because -7 volts is sufficient - no need for -12) to turn it on.

  • How to use it

    Nick Sayer07/13/2023 at 21:17 0 comments

    It turns out that there's not been a release of AVRdude for a while, and all of the additions of support for UPDI have only been recently added. So you need to fetch the trunk tip of the repository (see the linked project) and build it for yourself. But having done that, you can, for example:

    avrdude -c serialupdi -p t3226 -P /dev/ttyUSB0 -U flash:blinky.hex
    

View all 2 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates