Programming ATmega168 with the Tiny AVR Programmer

After much fuss trying to get AVRDude and Atmel Studio to work, I found if you are only looking to upload the Arduino bootloader and upload your Arduino programs, all you need is the Arduino program to program AVR chips! It is super easy once you have the software setup correctly.Sparkfun has some great steps for setting up the programmer, but doesn’t really get in depth about how to program larger chips. Here I’ll walk you through the basic steps I used, but if you run into a snag with software setup, try checking the link above.

I’m looking to put my program on an ATmega168A-PU chip. I’ll first describe setup for an ATtiny45-20PU chip, as this size chip is the programmer’s standard chip size to program.

Hardware

0319161145a

To program an ATtiny45, you will need:

The programmer can be inserted right into the USB jack on your computer, but I find it is much easier to work with on a USB extension cable.

Software

We will be using Arduino to program our chips, but first we need to setup the software. I will assume you have the latest Arduino program, but if not, download it here.

Plug the programmer into the computer. The correct drivers should install automatically, but if they do not successfully install, you can find them here.

You then must install the ATtiny addon for Arduino. The latest Arduino version is 1.6.X, and the ATtiny addon folder can be downloaded from Sparkfun here. Download the .zip file and extract the “attiny” folder to the Arduino hardware folder, usually located in C:\Users\userName\Arduino\hardware. If the hardware folder is not there, create one.

Hardware Folder

Now we can open up Arduino. Go to Tools > Board and click ATtiny. Under Tools > Processor, I’m going to choose my chip, ATtiny 45, and set the Tools > Clock to 1 MHz (internal). 8 MHz will make the program run slower (not sure why this is, as it’s a faster clock speed), and all of the external options will brick your chip unless you have an external clock/crystal hooked up.

After the chip is selected, choose Tools > Programmer: USBtinyISP and click “Burn Bootloader” (if a bootloader hasn’t been already installed, such as a brand new chip). If there is an error finding the programmer, there may be an error installing the driver. Follow the steps in Sparkfun’s guide to download and install the drivers.

You may test that everything is working by running the following sketch. The LED on the programmer is attached to Pin 0 of the ATtiny chip, and will blink on and off if correct.

Programming an ATMEGA168 Chip

One of the problems with the programmer is that it is not immediately obvious how the Tiny AVR Programmer can be used to program other chips. There is a group of 6 contact holes in the center of the board, and a row of 6 contact holes at the edge of the programmer. I have already soldered on a 6×1 right angle female lead to the contact holes at the edge. These six outputs from top to bottom are Reset, MOSI, MISO, 5V, SCK, GND.

Image courtesy of Sparkfun.

These six outputs should be connected to their matching pins on the ATMega Chip. Arduino has created this nifty pinout to refer to.

Image courtesy of Arduino.

Hardware

To program an ATMega168A-PU, you will need:

  • Tiny AVR Programmer from Sparkfun
  • ATmega168 microcontroller chip
  • USB Extension Cable (really handy, but optional)
  • Breadboard
  • 0.1 µF ceramic capacitor (104 printed on it)
  • Jumper Wires

The following image is the appropriate setup for programming the ATMega168A-PU. Note that a 0.1 µF capacitor is placed between VCC and GND to smooth out the powering up and powering down of the chip, and handle any minor fluctuations in the power supply. The USB extension cable is very handy, in that the connection wires do not have to be strung up beside your computer.

Programmer Diagram

Essentially, you connect the programmer outputs to their matching pins on the pinout diagram above. The capacitor is tied to +5V and GND to keep the power source stable.

0321161826

Software

At this point, if you try to select the ATMega168 chip from the Board or Processor submenu in Tools, you will not find it. You will not find it under the Boards Manager either. It’s a bit indirect, but a simple process which works for many different AVR microchips out there.

First, find your chip in the unofficial list of 3rd party boards/chips. I found my stand alone chip under Barebones ATmega Chips (no bootloader). There’s a link associated with that selection. Copy the link.

In Arduino, go to Files > Preferences. Paste the copied link into “Additional Boards Manager URLs” and click OK.

Arduino url

Adding that URL added a link in the Boards Manager to download the ATMega168 chip information. Open up the Boards Manager under Tools > Boards and find the pack for the new link you added. You can change the search filter type from “All” to “Contributed” to help only show packs you have added with URLs. Choose the pack and click “Install”. Then close the Boards Manager.

Now when you look through the Tool > Boards list, you will find your chip!

Leave a Message!

Your email address will not be published. Required fields are marked *