Atmel Studio with Arduino and USBasp

How to use USBasp to program Atmel chips from Atmel Studio 7, and also how to program the Arduino Uno directly.

Atmel Studio 7 is (was) Atmel’s IDE for programming AVR Microcontrollers, I really like this software as It’s based on Visual Studio and has a really nice user interface, unlike MPLAB X which I personally don’t like. The future of this I am not sure as MPLAB now supports AVR and as it’s now all the same company anything can happen.. I’d like to think they would keep them seperate and continue the AVR range.

If you want to break away from Arduino, but still use it to program without buying an expensive AVR programmer, then you can program direct to an UNO board or if you have a USBasp programmer you can use this too.

What you need.

Atmel Studio 7 – Free download from Microchip
Arduino IDE Installed
USBasp with drivers (if required)

Step 1: Go to Tools and Choose ‘External Tools’

Click Add, choose a title and the Command/Arguments and Initial Directory will be blank. Put the following in:

Command:
C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude.exe

Inital Directory:
$(ProjectDir)Debug\

Now for the middle one, Arguments it depends on what you want to do, options are below:

Arduino Uno (Note COM port number in bold, change this to your Unos COM port)
-C “C:\Program Files (x86)\arduino\hardware\tools\avr\etc\avrdude.conf” -v -p atmega328p -c arduino -P COM5 -b 115200 -D -U flash:w:”$(ProjectDir)Debug\$(TargetName).hex”:i

ATMega 328  and others, via USBasp:
-C”C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf” -v -p atmega328p -c usbasp -U flash:w:”$(ProjectDir)Debug\$(TargetName).hex”:i”

Change the bold parameter (-p) with the chip you want to program such as ATTiny4313 etc.

 

To Program your chip

First Build your project using F7 or Build > Build Solution

To program click Tools and then choose what you named your tool you just created

 

Limitations:

No software debugging in Atmel Studio
You still need a chip with the Arduino bootloader, as we’re still using avrdude which is part of Arduino to program the chip, all we are doing in studio is compiling the hex file from C.