In-System Programming Arduinos

Views: 9393 Difficulty: 2 Status: Development

An introduction to programming Arduinos using In-system programming

In-System Programming (ISP) is a useful way to get code onto a chip running Arduino. ISP uses the 6 pins found in the 2 by 3 header on most Arduino boards (and many LucidTronix boards too :). You will probably want to get an ISP programmer, but if you've got a spare Arduino you can turn it into one! If you decide to buy an ISP programmer you have a few options. Three we will mention are: The nice thing about options 1 and 3 is that they supply power, whereas with MKII you will need the USB plugged in while you program. Once you've got yourself a programmer and a board to program jump down to our step-by-step instructions and get started!

So Many ISP Programmers?! Which one is for me?

There are a plethora of USB to ISP programmers and programming options out there. Everything from hook-up wire into a breadboard to injection molded translucent blue enclosure with status LEDs. In this tutorial, we'll help you find out which way works for you.

Step-by-Step Instructions

Step 0 Connect the Ribbon to the 6-pin 3x2 headers on Your Board.

This is the ISP header on an arduino. Make sure the red wire on the ribbon lines up with 5V pin #1 of the ISP.

Step 1 Notice Orientation of ISP

The ISP Programmer has an orientation with pin #1 being high voltage line found in the corner.

Step 2 Select the Right Programmer

In the Arduino environment, go to Tools > Programmer and notice the list of programmers. Select the programmer you are going to use. Make sure a little check mark shows up next to name.

Step 3 Select the Right Board

Even though you may not be using a standard Arduino board, you still have to select the right one, based on which AVR chip you are using. If you are using the ATmega168 select Arduino Diecemilia / Dueminalove w/ ATmega168. If you are using a ATmega328p chip select Arduino Dueminalove w/ ATmega168. If you are using an ATmega32u4 then select Arduino Leonardo.

Step 4 Upload code Via the Programmer

Now when you upload the code you have to ensure Arduino uploads the code through the programmer. You can do this by either holding shift while clicking the upload button (as shown in the picture) or using the keyboard shortcut of ctrl (command on a mac)-shift-u.

Step 5 Common Errors

There are lots of places where ISP programming can break down. We will highlight two very common errors and offer some troubleshooting tips. One of the most common errors is to get a message (in big scary error code red) like: "avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)". Or, if you're using the MKII your error message may read "avrdude: usbdev_open(): did not find any USB device ". Okay this means your computer couldn't find the programmer. First is the programmer plugged in? Try unplugging and plugging it back into a different USB port. Also make sure you selected the right programmer under Tools > Programmer. Still not working? Try unplugging the board from the programmer and uploading again. If the error message changes that is progress, if not there may be something wrong with your programmer.

Step 6 The Dreaded Initialization failed, rc=-1

Oh how we hate this error! The exact error message reads "avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check." Here, the computer was able to talk to the programmer, but the chip was unable to respond to the programmer. As the error message suggests the first thing to check is the wires. Is there power for the chip? Are all the wires in the right places, is the red wire on the ISP ribbon lined up with pin 1 on the 6 pin header? Is there an unexpected short circuit? Are things getting hot? Unplug! Try a different chip if possible, try a different board if necessary.
Build your own clock with the MCP79410 chip and 4 7-Segment LED modules....
Think of it like a shift register for Pulse Width Modulation (PWM)....
Wall-ter is a wall following robot....
Rainbow flower necklace using the TLC5940....
Play pong on a little LCD screen with two big joysticks....
Control a 120v outlet with a 5V arduino....
How to upload code to an Arduino Leonardo clone....
An arduino library for the MMA8453 Triple Axis Accelerometer...