|SparkFun Tiny AVR Programmer|
×1 Software apps and online services:
The Atmel tinyAVR MCU’s (ATtiny) are a series of chips optimized for applications requiring performance and/or power efficiency in a small package. These have internal clocks that runs at 8 MHz. They can also be clocked at 16 MHz and 20MHz using an external clock. There is a limitation though when using an external clock. Two of the already limited I/O pins are used leaving you with just three. Well, did you know you can run it at 16 MHz without using an external clock?
If you have used the ATtiny, you are probably familiar with how to use it through the Arduino IDE. If not, here is a quick overview.
The first step is to add a URL to the Additional Boards Manager option in Preferences. Select Preferences from the File menu and add the URL below to the text box. If there is more than one URL in the box, separate them with a comma.
The second step is to install the board. In the Arduino IDE, click the Tools menu and then click Board. In the menu that appears, select Boards Manager. In the search text box type ATtiny to find the package for the this chip. Now, click the Install button to install the board.
After the install has completed, a new board option is available in the menu. The new board allows you to select an ATtiny45, ATtiny85, ATtiny44 or an ATtiny84. There is also a selection to run the clock at 1 MHz internal, 8 MHz internal, 8 MHz external, 16 MHz external or 20 MHz external.
To use an ATtiny, you will need to have a way to program the chip. It does not contain a bootloader or a USB interface. A programmer is needed to program these chips. I use the Tiny AVR Programmer from SparkFun which is designed specifically for the 8 pin chips. There are also a lot of articles on how to use another Arduino, such as an Uno, the program these MCU’s.
Here are a few links to help:
- Programming ATtiny85 with Arduino Uno on Hackster.io
- Virtual Workshop: Program an ATTiny85 with Arduino
- Programming an ATtiny w/ Arduino 1.6 (or 1.0)
- Programming an ATtiny w/ Arduino 0022
Once setup, programming is easy through the IDE and works like any other AVR with some minor limitations. For example, there are a limited number of ports and less available RAM. Most of the chips do not have support for hardware serial. The I2C is also a bit different and does not work with the standard Wire library. Instead, you will need to use the TinyWireM and TinyWireS libraries.
One caveat of programming is, when using a brand new chip, or when changing the clock speed, you need to choose Burn bootloader from the menu. This will set the fuses on the chip so that it runs at the selected clock speed.
NOTE: be careful to NOT select external clock unless you have actually connected an external clock. Doing so will “somewhat” brick the chip. What I mean by somewhat is that, unless you have a high-voltage programmer to reset the fuses, or an external clock to connect to the chip, you will be unable to use it. If you are using, or plan to use a lot of these, it is a good idea to have high voltage programmer. I use the HV Resuce Sheild in the event I need to reset the fuses.
Adding 16 MHz (internal)
Adding the 16 MHz internal options requires updating the boards.txt file. To edit this file, you first need to open the folder where the file is located. To do this, select the Preferences option from the File menu. Near the bottom of the page is a link to the edit the preferences file directly. Clicking this link will open the folder where the board files are located. Click the link and open the folder.