Using AVR-USBasp to Program Arduino

Generally, there are two methods to load the program into Arduino:

  1. USB/Serial Communication method
  2. ISP method

The first method is the most common method, which implemented using USB-to-serial adapter chip/converter. For example, CT-UNO is using FTDI FT23x chips which is a popular USB-to-serial adapter chip, and BBFuino requires UC00A USB-to-serial converter to load the program. While original Arduino UNO uses Atmega32u4 as USB to Serial chip (similar with CT-UNO). The method applied on CT-UNO can be applied to Arduino UNO.

Another method is ISP method, where a ISP programmer is needed. ISP (In-system programming) is a method used to program those fresh blank Atmel AVR chips. If the Atmel AVR chips are not pre-loaded with bootloader firmware, ISP method can be used to load the program into the chips; bootloader method will not work. Just like tutorials “Using ISP Programmer to Burn Bootloader into Arduino” and “Burning Arduino Bootloader with AVR USBasp“, we used ISP to burn the bootloader into Arduino. This tutorial will shows you how to load the program into Arduino using ISP programmer – AVR USBasp, and there are 3 sessions in this tutorial: 

  1. Load Program into CT-UNO
  2. Load Program into BBFuino
  3. Load Program into Standalone Arduino

 

Introduction

5116-600x800

AVR USBasp is an USB in-circuit programmer and can be used to program most of Atmel AVR microcontroller. It simply consists of an ATmega8 and a couple of passive components, i.e. resistors, capacitors, LEDs and etc. This programmer uses a firmware-only USB driver and there is no special USB controller is needed. AVR USBasp came with 6-way cable. Figures below will tell you what all the holes in the cable head are: 

6pinAVRprogcable

This figure is a view from the top and label each of the holes. Take note of the square as to what orientation your cable is in. 
6pinAVRproghead

The ISP header consist of 2×3 pins. You will notice there is a label of ‘1’ or an arrow label beside the ISP header. This label indicate the pin beside it is the pin 1 of the ISP header. 

C360_2015-02-05-10-10-39-234           C360_2015-02-05-10-11-35-077

Before proceed to the next step, make sure you install the AVR USBasp driver into your PC. If you haven’t, download the AVR USBasp driver and follow the instruction in the AVR USBasp User Manual

Session 1: Load Program into CT-UNO

  1. Insert the ISP programmer cable socket onto ISP header. The plastic nub of the rainbow cable head and the arrow label should be on the same side. C360_2015-02-05-10-22-10-150You will notice the PWR LED is ON. If it is not, please check the connection between cable head and ISP header. 
  2. Open Arduino IDE software. If you are using older version of Arduino IDE, you may receive some error. Download the latest version from Arduino website. I am using Arduino IDE version 1.0.5 and it works fine.
    001
  3. Next, call out any example of source code. This tutorial will use the Blink example which can be called out from the File > Example > Basics > Blink menu.
    002
    The sketch of Blink example:
    003
  4. Select “USBasp” from the Tools > Programmer menu.
    004
  5. Select “Upload using Programmer” from the File menu. The uploading process will takes a minute.
    005
    If you select “Upload” or click “upload” button, you will receive an error as shown in figure below. This is because AVR USBasp is not installed as Serial port in our PC, and “Upload” function stands for upload the program via serial port. Do not worry, the IDE will still upload via USBasp.
    007
  6. The uploading process is done when Arduino IDE display “Done uploading” 
    006

 

Session 2: Load Program into BBFuino

BBFuino is using ATmega328 IC instead of ATmega328P IC (at the time this tutorial is written).
C360_2015-02-05-22-35-43-393

The difference between ATmega328 and ATmega328P is ATmega328P has the Atmel picoPower technology while ATmega328 does not have. The identification signature of ATmega328 and ATmega328P are different too. ATmega328 has the signature of 0x1E 0x95 0x14 while ATmega328P has the signature of 0x1E 0x95 0x0FB. Other than that, ATmega328 and ATmega328P are the same every sense architecturally. To upload sketches into ATmega328, some modification of configuration is needed: 

  1. Locate your Arduino directory. In my case, my Arduino directory is C:\Users\user\Desktop\arduino-1.0.5
    Then, locate the directory hardware\tools\avr\etc. You will notice there is a file named “avrdude.conf” inside that directory.
    ScreenShot017
  2. Make a copy of file “avrdude.conf” for backup purpose.
    ScreenShot024
  3. Open the file “avrdude.conf” using WordPad.
    ScreenShot018
  4. Search for “m328p”.
    ScreenShot019
  5. Look for “signature”. It should be few lines under “m328p”. 
    ScreenShot020
    Change 0x1e 0x95 0x0f to 0x1e 0x95 0x14
    ScreenShot021
  6. Click “Save” to save the edited configuration file and close it. Now you done modified the configuration of Arduino IDE. 

Next, plug the ISP programmer cable head onto the ISP header of BBFuino. The plastic nub of the rainbow cable head should be on the same side of the “ISP” label on the BBFuino.
C360_2015-02-05-15-31-25-976

The procedure to upload sketches into BBFuino is similar with session 1:  

  1. Open Arduino IDE software and call out any example. This tutorial will use the Blink example which can be called out from the File > Example > Basics > Blink menu. 002
  2. Select “USBasp” from the Tools > Programmer menu.
    004
  3. Select “Upload using Programmer” from the File menu. The uploading process is done when Arduino IDE displays “Done uploading”.
    005

 

Session 3: Load Program into Standalone Arduino

In this session, the hardware required are: 

Construct the circuit of standalone Arduino as shown in below: 

ATmega basic circuit_bb

 

Figures below will be good reference when you connect AVR USBasp and standalone Arduino: 

6pinAVRprogcable    6pinAVRproghead

Source: Arduino.cc

There is no ISP header on standalone Arduino. So we use male-to-male jumper wire to do some wiring between cable head and standalone Arduino. Refer to table below for the connection: 

ISP Programmer  

Cable Head

Standalone Arduino
Pin 1: MISOPB4 (MISO / digital pin 12)
Pin 2: VCCVCC
Pin 3: SCKPB5 (SCK / digital pin 13)
Pin 4: MOSIPB3 (MOSI / digital pin 11)
Pin 5: RESETPC6 (RESET)
Pin 6: GNDGND

USBasp to ATmega_bb

The procedure to upload sketches into standalone Arduino is similar with session 1. Select “USBasp” from the Tools > Programmer menu and choose “Upload using programmer” menu. 

004

005

The uploading process is completed when Arduino IDE displays “Done uploading”. 

Great! I’m done sharing the ISP method to upload sketches into Arduino, hopefully it is helpful and if you have any inquiry, please do discuss in our technical forum as we seldom check the comment section in tutorial site. Please take note that there is a limitation for this method, that is the bootloader firmware is being replaced by the source code of the blink example. To go back to uploading sketches using USB, you’ll need to burn the bootloader into the chip on the Arduino board. Refer to Burning Arduino Bootloader with AVR USBasp to burn the bootloader onto Arduino using AVR USBasp. 

Buy

, , ,

Related Post

Getting Started with Colour Sensor Module (SN-COLOUR-MOD)

Getting Started with Tilt Sensor (SN-TILT)

Getting Started with Vibration Sensor Module (Normally Off) (SN-VIBRATE-MOD)

Getting Started with IR Distance Click

One thought on “Using AVR-USBasp to Program Arduino

Leave a Reply

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