You may be familiar with the ATtiny series of microprocessors from Microchip such as the ATtiny85 or ATtiny2313. These chips powered small systems like the Digispark series. Unfortunately, they had limited Flash (usually no more than 8K) and even more limited RAM (usually less than 1K).
Now a new series of ATtiny chips are available with more memory and functionality. They even compete with the more expensive and larger ATmega range of chips.
One of the biggest changes in these processors is the way they are programmed. They use a system called Unified Program and Debug Interface (UPDI for short). In this build you can create a UPDI programmer for under $10 rather than having to fork out many hundreds of dollars for a commercial one.
The SchematicA Nano, resistor and capacitor are all the basic components required. To save on a case, a piece of 1 inch transparent heatshrink and a 6 pin header are used to complete the build.
Unzip the attached "SpenceKonde - jtag2updi.zip" file into your Arduino program folder and program the Arduino Nano. Note: It's OK that the jtag2updi.ino file is empty as the actual code resides in the other files.
Step 2 - Modify and solder on the pin headerThe 4K7 resistor goes between pin D6 on the Arduino Nano and the top center pin on the header. Use some insulation material to ensure the lead doesn't short with other components.
The 10uF capacitor is soldered between the GND and RST pins. Make sure the positive end (usually marked with a line or + symbol) of the capacitor is soldered to the RST pin.
Finally slide on the heat-shrink sleeve and apply heat evenly along the sleeve. Being transparent, you can still see the lights and you should still be able to press the reset button on the Arduino Nano.
Add a bit of red paint or nail varnish to the +5V side of the pin header since the pin header is not polarized and you don't want to accidentally plug the lead in upside-down.
Step 4 - Make up a leadCreate a simple lead. I choose to use female pin headers on both ends (a 1x3 female header at one end and three 1x1 female header at the other end). You may want to use test hooks instead. Just make sure the wire colors used make it obvious which wire is +5V, which wire is GND and which wire is UPDI.
To use the programmer, you must first install the megaTinyCore into the Arduino IDE via the board manager.
- File -> Preferences, enter the following URL in "Additional Boards Manager URLs"
http://drazzy.com/package_drazzy.com_index.json
- Tools -> Boards -> Boards Manager...
- Select "megaTinyCore by Spence Konde" and click "Install".
Once the board has been installed in the IDE, select it from the Tools menu.
Make sure you select the Chip that you are about to program. Also libraries such as the Adafruit Neopixel Library won't work on a 20 MHz clock so you may need to wind the clock speed back to 16 MHz or 8 MHz if you are running the chip from a 3V3 supply.
The Programmer needs to be set to jtag2updi (megaTinyCore).
Pin mapping and the Arduino IDETo access the physical IO pins in the Arduino IDE using digitalRead, digitalWrite, analogRead or analogWrite, use the pin map above to determine the pin number to use. Note: Unlike the ATmega328, the new ATtiny processors don't have separate analog pins. Whether a pin is analog or digital depends on which function you use to access it.
ConclusionI suggest you read my tutorial for some demonstration code samples. The datasheet is worth reviewing as these chips have more timers, a built in DAC, an analog comparator and configurable custom logic.
Comments