-
Another possible way to go
07/14/2023 at 22:31 • 0 commentsI'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
07/13/2023 at 21:17 • 0 commentsIt 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