Introduction: AVR Progamming Shield for Arduino
Do you need a quick and easy way to program AVR chips. Did you know you can use your Arduino and the Arduino IDE? This Arduino shield makes the process much easier.
You can:
- Burn a bootloader onto a replacement Atmega328 for your UNO.
- Make a stand-alone Atmega328 breadboard project.
- Use inexpensive Attiny chips for smaller projects.
- Reprogram a chip in an existing circuit with an ISP header.
This shield lets you:
- Quickly setup to program chips.
- Program a variety of chips easily:
- 8, 14, and 20 pin Attinys.
- 28 pin Atmega168 or Atmega328.
There are a lot of AVR programming shields available. That is why we call this one "Yet Another Programming Shield", or YAPS for short. We think ours has a lot of advantages. If you want to learn more about how we developed it, check out http://makersbox.blogspot.com/2013/12/anatomy-of-small-open-source-hardware.html
This project was recipient of a 2013 Innovation Grant from Wyolum which helped us get it to the kit stage.
The kit is available on Tindie.com. Purchasing the kit will save you the time and expense of ordering from several different vendors and avoid the minimum PCB order premium. You will also be helping us develop and share other projects!
Step 1: Gather the Parts
To start, check to see you have everything:
Bill of Materials:
- PCB available at OSH Park ($20.70 for three copies).
- (1) x 28-pin DIP ZIF socket
- EMSL 9220005 $2.25ea
- Adafruit 382 $3.00
- Sparkfun ZIF PRT-09175 $2.95
- $2.50 (EMSL) 3" - or-
- 2 x Ribbon Crimp Connector - 6-pin (2x3, Female)
- Sparkfun PRT-10651 $0.35ea
- Digikey 609-2842-ND $0.90
- Digikey 609-2841-ND $0.82
- Digikey 1080-1106-ND $0.33 green,
- Digikey 1080-1115-ND $0.33 red,
- Digikey 1080-1123-ND $0.33 yellow
Optional (for Arduino Mega):
- (1) x 2x2 female header Digikey A26452-ND $1.25
- Four male jumpers
Optional (for Optiboot or Adaloader):
- (1) x Piezo Buzzer
- PS1240Adafruit 160 $1.50
- Digikey 445-2525-1-ND $0.73
Step 2: Gentlement, Start Your Iron
We are going to assume you have some kit-building experience. If you need some help soldering, head over to http://www.sparkfun.com/tutorials/213 to brush up.
The order of assembly is largely a matter of preference. If you don't have a helper or a vice, I generally go from lowest height to tallest so when the board is reversed on the table, the parts stay in place. Picture numbers correspond to the step numbers:
- Three 330-ohm resistors
- Tactile button
- LEDs:
- Long lead is positive. Look for the "+" on the PCB.
- Green -> Heartbeat, Red -> Error, Yellow -> Programming
- Use the ribbon crimp connector to hold the header in place.
- Solder one pin on each opposite side, check the seating, and then finish.
- It is easiest to place them in an Arduino first to hold them in alignment.
Inspect the board for missing, bridged, or incomplete solder joints. Solder bridges can be fixed using solder braid or a solder-sucker.
Step 3: Jumper and Options
- The jumper cable is creating by placing one end of the six-strand cable in between the upper and lower parts of the crimp connector and then applying enough pressure to make it lock. Do not use pliers. Use something flat to press down on it.
- With one crimp connector in place, put the jumper on the ISP header and check the length you need to reach the far Attiny85 header.
- Crimp the remaining side on and trim the excess.
Arduino Mega:
This shield will work with the mega, but needs a 2x2 female header added in the lower right corner and four jumper wires to connect with Mega pins 50 - 53.
Adafruit's Sketches:
Adafruit has modified ArduinoISP to give audible indication of programming status. You can add a piezo speaker to the underside of the board.
Adafruit has also modified the Optiboot sketch which will allow you to upload a bootloader or firmware to just about any AVR chip. This process can be done stand-alone, and is very quick if you have a lot of chips to program.
Step 4: Setup Arduino and IDE
If you want to program anything other than the standard bootloaders, you will need to add the appropriate "cores" to the Arduino software:
- For a "Breadboard Arduino", which is an Atmega328 running on its internal crystal at 8 MHz, you must install the files from "Breadboard.zip" at http://arduino.cc/en/Tutorial/ArduinoToBreadboard into the "hardware" folder in your Arduino "sketchbook" folder.
- For Attiny chips, there are several cores available:
- I like Arduino-Tiny core based on work by David A. Mellis, René Bohne, R. Wiersma, Alessandro Saporetti, and Brian Cook because it supports the tone() command if you want to play sounds on a piezo speaker.
- If you want to program the Attiny2313, you can use the Attiny core.
Setting the settings:
- The stock Arduino software comes with the "ArduinoISP" sketch in the "Examples" section. This sketch must be uploaded without the shield in place since the shield has a capacitor to over-ride the reset signal (or you could use a manual reset before upload, like in the old-old days).
- With the sketch uploaded, install the shield. You should see the green heart LED begin it's pulsing.
- In the IDE, select "Tools" -> "Programmer" -> "Arduino as ISP".
- Select the target chip type using "Tools" -> "Boards".
- Place the jumper cable between the "ISP" header and the correct header for the chip type.
Feel the burn:
Setting fuses is a scary and confusing topic if you look in to it much. Don't bother. They are basically setting that tell the chip how to behave and have to be done only once to a new chip.
- Place the chip in the ZIFF socket, all the way to the left, with Pin 1 in the lower-left corner.
- With the correct "board" selected for the target chip, select "Tools" -> "Burn Bootloader".
- For an Atmega chip going in to a UNO or breadboard, this will set the fuses and upload the correct bootloader.
- For an Attiny, this just sets the fuses. For us, this primarily concerns chip speed.
Upload a Sketch:
- Load the sketch for the target chip. Start with the basic blink "File" -> "Examples" -> "01.Basics" -> "Blink".
- Change the "led" variable from "13" to "3".
- Click the upload icon, or "File" -> "Upload".
- You should see the yellow LED flash and get an "Upload Complete" message.
- If all is well, the target chip should start blinking the yellow LED (attached to D3).
If all is well, pat your self on the back and start planning your next project. If not, move to the next step to do some trouble shooting.
Step 5: Shoot the Trouble
Troubleshooting:
Go back and check the following:
- "Tools" -> "Serial Port" -> Correct port selected.
- ArduinoISP sketch uploaded and green heartbeat beating.
- Sometimes the sketch will hang and need a reset.
- "Tools" -> "Programmer" -> "Arduino as ISP".
- "Tools" -> "Boards" -> target chip selected.
- Jumper cable set to correct target ship type.
- Target chip in the correct position with pin 1 to the lower left.
We've tried hard to make this as easy and trouble free as possible, but it is still a pretty advance topic as far as life in Arduino Land goes.
- Have faith you can figure it out.
- Run through the steps again.
- Google it.
- Then ask for help.
Step 6: Some Notes on Attiny Cores
PAGEL and BS2 Warnings:
AVRdude, which is the underlying software for talking to AVR chips generates the following warnings for Attinys:
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny84 avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny84
These warnings can be ignored.
Digital and Analog Pin Numbers:
If you want to engage pullup resistors, and then read an analog value, you need two pin numbers which may or may not match. Take a look at the Attiny85:
// ATMEL ATTINY45 / ARDUINO<br>// // +-\/-+ // Ain0 (D 5) PB5 1| |8 VCC // Ain3 (D 3) PB3 2| |7 PB2 (D 2) INT0 Ain1 // Ain2 (D 4) PB4 3| |6 PB1 (D 1) pwm1 // GND 4| |5 PB0 (D 0) pwm0 // +----+
Note that A3 and D3 are the same, but if you want to engage the internal pull-up resistor on PB2 (physical pin 7), you need the following:
pinMode(2, INPUT);
digitalWrite(2, HIGH); int val = analogRead(1);
A bit confusing. Let me know if you figure out a better way to handle this!
Attiny84 Pin numbers:
Depending on the core you use, the pin numbers are different!
/* “tiny” CORE, aka https://code.google.com/p/arduino-tiny/:
Arduino-Tiny is based on work by David A. Mellis, René Bohne, R. Wiersma, Alessandro Saporetti, and Brian Cook. “attiny84at8.name=ATtiny84 @ 8 MHz (internal oscillator; BOD disabled)” ATMEL ATTINY84 / ARDUINO +-\/-+ VCC 1| |14 GND (D 0) PB0 2| |13 AREF (D 10) A0 (D 1) PB1 3| |12 PA1 (D 9) A1 PB3 4| |11 PA2 (D 8) A2 PWM INT0 (D 2) PB2 5| |10 PA3 (D 7) A3 PWM A7 (D 3) PA7 6| |9 PA4 (D 6) A4 PWM A6 (D 4) PA6 7| |8 PA5 (D 5) A5 PWM */
/* “attiny” CORE aka https://github.com/damellis/attiny/, David A. Mellis “attiny84-8.name=ATtiny84 (internal 8 MHz clock)” ATMEL ATTINY84 / ARDUINO +-\/-+ VCC 1| |14 GND (D 10) PB0 2| |13 AREF (D 0) (D 9) PB1 3| |12 PA1 (D 1) PB3 4| |11 PA2 (D 2) PWM INT0 (D 8) PB2 5| |10 PA3 (D 3) PWM (D 7) PA7 6| |9 PA4 (D 4) PWM (D 6) PA6 7| |8 PA5 (D 5) PWM */
Step 7: Developing Attiny Sketches on Arduino Board
Developing a sketch for an Attiny can be a bit challenging because it is hard to figure out what is occurring on the chip. With Arduino, you can use Serial.print() to get debugging information easily on the console. Since the actual processing under the AVR hood is very similar, shouldn't you be able to write and test something on Arduino, and then upload it to an Attiny?
Yes! Take a look at the following Blink example, which will compile and run for either an Attiny84, Attiny85, or Arduino:
// Use preproccessor commands to determine board type and pin assignments #if defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny84__) #define ARDUINO 0 #define led 3 #else #define ARDUINO 1 #define led 13 #endif void setup() { pinMode(led, OUTPUT); #if ARDUINO Serial.println("I'm an ARDUINO!"); #endif } void loop() { digitalWrite(led, HIGH); #if ARDUINO Serial.println("LED ON"); #endif delay(1000); digitalWrite(led, LOW); #if ARDUINO Serial.println("LED OFF"); #endif delay(1000); }
Step 8: Other Uses
In addition to placing DIP chips in the ZIFF socket, you can also use adapter sockets to pre-program SMD chips. For my I Can Surface Mount Solder kit I use a DIP to SOP adapter in the ZIFF socket (Image 1). For the Misery Edition of the SMD Challenge, I use a QFN to DIP socket wired to ISP lines (Image 2).
I also use a pogo adapter from Geppetto Electronics to program Geek Spinners after they have been assembled (Image 3 & 4).
Finally, in case you need to program a 3.3V volt system, you may need to use a level shifter. I've used a SparkFun TXB0104.

Participated in the
Arduino Contest
12 Comments
7 years ago
Hi
I just received my shield. I am able to burn bootloader successfully for ATMega328P-PU , but unable to upload blink sketch to it
Here is the error i am getting. Can anyone help please??
Warning: Board breadboard:avr:atmega328bb doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA328BB
Sketch uses 1,066 bytes (3%) of program storage space. Maximum is 30,720 bytes.
Global variables use 9 bytes of dynamic memory.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xeb
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x1c
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
8 years ago on Step 4
Hey guys, I just purchased this kit with the intentions of being able to easily set fuses. Then I read: "Setting fuses is a scary and confusing topic if you look in to it much. Don't bother.", which has me a little disappointed.
Can you please explain to me what would be the best way to get fuse-changing capabilities?
(In the past I've changed fuses using AVRdude, but I was hoping to have fuses changed all in one go when I burn the bootloader)
Thanks for all the great work.
Reply 8 years ago on Step 4
AVRdude can be used with the programming shield using the command line.
With the Arduino IDE, using the "burn bootloader" option, it will automatically set the fuse for the targeted board.
Let me know if you have a specific chip or options you are going after.
Reply 8 years ago on Step 4
Thanks for the response.
I spent all day trying to figure this out. (boot-loading w/ my desired fuse values all in one go).
I ended up using the adaLoader from adafruit, because their code could be modified to allow me to change the fuses, as explained here:
https://learn.adafruit.com/standalone-avr-chip-pro...
Changing the "pre program fuses" in the images.cpp was easy enough, and since I was testing this bootloader option on the same atmega328P that the adaLoader example uses, I didn't have to modify any of the HEX (for different chips... like I would have to do if I wanted to boot onto the ATtiny's).
.
The downside to using the adaLoader seems to be:
1. You need to flash the host arduino (the arduino under the YAPS shield) for each different model chip or fuse-changes that you want.
2. You also need to modify the images.cpp code for each different model chip / fuse change. (which means you need to get the ideal HEX for each model chip, format the HEX in the same way as shown in images.cpp, and you need to know the signature bytes of the model chip, and then update the pageBuffer[x] size accordingly. (lots of work, but end result would allow wicked-fast boot-loading that doesn't require a computer for a particular model chip)
.
If I wanted to use the method explained in this Instructable, (use the Arduino IDE to burn) then it seems in order to get desired fuse-settings in the same burn-opteration, I would need to (for example) modify the ATmegaBOOT_168_atmega328_pro_8MHz.hex file to burn the fuse values I want. I'm just lost as to where in the HEX file I could find/replace the fuse values. (any idea?)
.
I'm not familiar with using AVRdude (it took me much too long just to figure out how to use AVRdude to change fuse settings).
Reply 8 years ago on Step 4
It is important to realize that the bootloader (or "hex") file is for using the Arduino IDE and typically involves the Atmega 168/328 family chips and allows uploading the compiled sketch (which is also a hex file) through the IDE via USB. The process of burning a bootloader through the IDE both sets the fuses and uploads the bootloader program to the chip.
For Attiny family chips (Attiny 84, 85), there is no bootloader (unless we start talking about Micronucleus). Using the "burn bootloader" function only sets fuses. The Arduino IDE actually provides an empty "dummy" hex file to allow a similar process as the Atmegas.
When you "upload using programmer", the IDE sketch like "blink.ino", for example, the hex file is directly uploaded to the chip (erasing the bootloader if it exists).
So, in summary, the programming shield can:
- Place an UNO bootloader on a chip.
- Set Attiny fuses (brownout, clockspeed, etc.)
- Load a sketch directly (without a bootloader).
If you are trying to do something like put a bootloader on a 328P instead of a 328P-PU try using https://github.com/WestfW/OptiLoader which is like Adafruit's stand-alone loader, but detects the difference.
Reply 8 years ago on Step 4
I ended up asking the question on the Arduino Forum: http://forum.arduino.cc/index.php?topic=344902.new...
(in case any future visitors wanted to see if I found a solution)
9 years ago on Introduction
I opted for the kit, everything arrived promptly and was assembeled in about 20 mins.. Thanks Ken!
Reply 9 years ago on Introduction
Look out! The're in the wild!
Super. Let us know what you make with it!
9 years ago
are all the arduino uno commands and libraries compatible with the attiny? if so i am gonna make it right away.
Reply 9 years ago
Not all, but most of the basic commands (from http://highlowtech.org/?p=1695):
pinMode()
digitalWrite()
digitalRead()
analogRead()
analogWrite()
shiftOut()
pulseIn()
millis()
micros()
delay()
delayMicroseconds()
Here is an example of one of my Attiny projects: http://youtu.be/9hu26QAcnC0?t=1m25s
Reply 9 years ago
well, thats good enough. i will be making it and will be posting the pictures soon. awesome project. you got my vote!
9 years ago on Introduction
Looks like a lot of hard work went into this, cant wait to try it out! Its not just another programming shield, its a lot more.