Skip to content
All prices in US$ - All orders receive free delivery, worldwide - Click here to learn more
All prices in US$ - All orders receive free delivery, worldwide - Touch here to learn more
Loading Firmware Onto an ATtiny with a Homemade UPDI Programmer

Loading Firmware Onto an ATtiny with a Homemade UPDI Programmer


Shrinking down projects
Stemming partly from the ongoing chip shortage, makers have been trying to find ways in which they can "shrinkify" their projects by switching from larger microcontrollers to tinier, more fitting ones. By doing so, they can free up their more valuable components, reduce overall cost, and have their devices consume less power — all simultaneously. And due to the recent release of the new lineup of ATtiny chips, embedding a cheap yet capable microcontroller into a project has never been easier to accomplish.

For Clem Mayer's project, he wanted to swap out his current MCU for an ATtiny but also avoid programming it via the ICSP protocol due to the extra pins and costs. Therefore, he decided to try out the UPDI interface by building his own homemade programmer.

What is UPDI?
The acronym UPDI stands for Unified Program and Debug Interface. It is a successor to PDI, both of which are proprietary interfaces invented by Microchip. UPDI enables certain microcontrollers to be both programmed and debugged over a single wire. The signal it carries is half-duplex, meaning bidirectional communication, and also asynchronous, meaning it doesn't have an external clock source. This allows for fewer connections and a smaller programming header.

Rather than spending a fortune on an expensive programmer, Mayer was able to source the inexpensive Arduino Nano, which is based around the ATmega328P. In terms of passive components, a 4.7k ohm resistor is needed to sit between the programmer's output pin (D6 in this case) and the target's UPDI pin. A 10uF capacitor was also placed between the RESET and GND pins of the Arduino Nano.

Converting USB to UDPI
Having to program your own bit-banged firmware that takes in serial data from the USB port and converts it to a UPDI signal would be very tough, so instead, Mayer went with a project called jtag2updi from GitHub user ElTangas. This program, once flashed onto the Nano, does all of the heavy lifting by communicating with the Arduino IDE and outputting the correct signals as needed.

Fabricating the programmer
Putting together the board was quite easy, as Mayer soldered a piece of perfboard underneath the Nano, attached the capacitor and resistor, added a programming header, and placed a jumper to the side that lets the user select either 5V or 3.3V output to protect sensitive circuitry on the other side. From here, he designed and 3D printed a stylish case that hides the Nano while only exposing the necessary header pins. And finally, the target ATtiny212 was soldered to a breakout board of its own along with an LED to view the result.

Using it from the Arduino IDE
By installing the megaTinyCore Arduino board package, Clem could easily select his ATtiny212 from the drop-down menu as well as the clock source, enabled timers, and most importantly, his custom programmer. Clicking the "Flash with programmer" button immediately caused the Nano to begin sending the UPDI signal to the target, and after a quick reset, the ATtiny212's LED began to blink.

To see more about this project, you can watch Mayer's video here on YouTube or read about it on element14's community page.

Finally - to keep up to date with interesting news, offers and new products - interact with us on facebookinstagram, and twitter.

Previous article Andy Green's Libwebsockets Can Parse and Render HTML5, CSS on an ESP32 or Other Microcontroller

Leave a comment

Comments must be approved before appearing

* Required fields