Programming an ATtiny Microcontroller with AVR Studio and Atmel STK500

This is a tutorial for programming an Atmel AVR ATtiny12, ATtiny13, ATtiny22, ATtiny25, ATtiny45, or ATtiny85 8-pin microcontroller chip using the Atmel STK500 tool. These instructions assume that you have a Windows OS computer, an ATtiny chip, and the object file that you want to program onto it.

Obtain AVR Studio 4 from the Atmel Website

AVR Studio 4 is a free programming and debugging environment from the microcontroller’s manufacturer. Presently, AVR Studio 4 is located at the following Internet address: http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2725

It is likely that the address will change in the future. If so, then go to Atmel’s website and search for “AVR Studio”.

Atmel website searching for AVR Studio

Atmel website searching for AVR Studio.

Click on the AVR Studio 4 link on the search results page. Towards the bottom of that page is the section containing downloadable software. You want to download AVR Studio 4 and the most recent service pack.

Download section for AVR Studio

Download section for AVR Studio.

AVR Studio 4 is version 4.18 (at the time that this article is being written). You need to register to download the software. I’m not sure why they bother. I imagine they get a lot of goofy registration names.

The current service pack is SP3 (at the time that this article is being written). It includes the functionality of the previous service packs. This may change in the future, so check their website for details.

After downloading the software, install AVR Studio 4 and any service packs.

Purchasing STK500 Programming Tool

The Atmel STK500 board is inexpensive ($80), versatile, and supports most of the AVR microcontrollers in DIP packages. You can make your own adapter boards for newer chips, such as the ATtiny84 and ATtiny861.

Unfortunately, Atmel has decided to obsolete the STK500. The STK600 is much more expensive and requires a set of socket adapters to provide the same base functionality. So, most hobbyists are sticking with the STK500 while it is still available.

Obtain the Atmel AVR Programmer Starter Kit STK500 from Digi-Key ($82.19, ATSTK500) or Mouser ($79.00, 556-ATSTK500). If you don’t have an old-fashioned DB9 RS232 serial port, you'll need to buy a USB-to-serial adapter.

Also, you'll need an external 500 mA @ 10-15V DC power supply with a negative center and a 2.1 mm ID / 5.5 mm OD barrel plug. Digi-Key ($6.98, EPS120050-P5N) or Mouser ($19.28, 802-SPS-0612).

You may want to order the desired ATtiny chip when you buy the STK500 and power supply. This example page uses the ATtiny45. Digi-Key ($2.31, ATTINY45-20PU) or Mouser ($1.87, 556-ATTINY45-20PU)

Setting Up the STK500

The STK500 should be set up as follows.

Atmel STK500 programmer setup for tiny AVR 8 pin chip
  1. Power supply
  2. RS232 DB9 serial cable connected to the PC
  3. Jumpers attached. (Details later)
  4. Ribbon cable connecting ISP6PIN to SPROG1 (blue). Note the red wire goes straight horizontally. The cable is installed incorrectly if the red wire crosses from the top of one connector to the bottom of the other connector.
  5. ATtiny microcontroller in DIP socket SCKT3400D1 (blue) with pin 1 (small circle or dot on chip) facing down towards the notch. (Details later)
  6. Wire connecting PORTE/AUX RST PORTB PB5. Another wire connecting PORTE/AUX XT1 to PORTB PB3. (Details later)

Jumpers

The headers on the jumpers should be set as illustrated below.

STK500 jumper placement for ISP programming 8 pin tiny chip

STK500 jumper placement for ISP programming 8 pin tiny chip.

ATtiny Chip Placement

With the power turned off, make sure to place the ATtiny chip with pin 1 nearest the notch on the blue silkscreen under the STK3400D1 8-pin socket.

8 pin tiny Atmel AVR chip with dot toward notch in STK500 programmer socket

8 pin tiny Atmel AVR chip with dot toward notch in STK500 programmer socket.

If you insert the chip into the socket in the wrong orientation, it could become damaged since the power is supplied to the incorrect pins. I’m embarrassed to admit that I’ve done this many times, and so far the chip has survived.

Clock and Reset Pin Connections

By default, the clock and reset signals from the STK500 are not connected to any pins on the STK3400D1 8-pin socket. Requiring you to make a couple of connections allows a wide variety of chips to be supported by the same programming tool.

Using a wire, hook test lead, or half of each of the supplied 2-wire cables, connect RST (reset) on PORTE/AUX to PB5 on PORTB. And, connect XT1 (clock signal) on PORTE/AUX to PB3 on PORTB.

Jumper wire leads for ISP programming Atmel AVR tiny 8 pin chip in STK500

Jumper wire leads for ISP programming Atmel AVR tiny 8 pin chip in STK500. Note that only the blue and green wires are used. The yellow and white wires just hang off the ends.

Another way of looking at it is:

STK500 ATtiny wiring with IC hook test leads

STK500 ATtiny wiring with IC hook test leads.

Next, let’s run AVR Studio and see if we can connect to the STK500.