Edit: Check out the new version of this tutorial, using Atmel Studio 6!Part 1: Using Atmel Studio with Arduino BoardsPart 2: Using Atmel Studio and Arduino Code with Arduino BoardsPart 3: Using custom Arduino libraries in Atmel StudioWhy AVR STUDIO?
Because Arduino IDE is slow, and WinAVR is awful to use.
AVR Studio is a really convenient IDE, based on Visual Studio and released by ATMEL itself.
It includes an astonishing number of 474 example projects, but none for Arduino boards, which need a bit of configuration to be used. But once this is done, coding with AVR Studio becomes really convenient, intuitive and efficient!AVR Studio 5 description pagehttp://www.atmel.com/microsite/avr_studio_5/default.asp?category_id=163&family_id=607TUTORIAL:1- Download AVR Studio 5.0
Two ways for that, either the long and Atmel way, which needs registration
Or the short way, directly with the download link from Atmel serversDOWNLOAD LINK AVR STUDIO 5.0
Current version: 5.0.1223 (since 11.11.2011)2- Install AVR Studio 5.0
Run the installer and follow the steps.
You will go through 4 major installations: Microsoft Framework 4.0 (which will require a reboot), Visual Studio 2010 SHELL, USB Drivers and AVR Studio 5.0.
Run AVR Studio and let it set the environment for the first time.3- Get the extensions
C++ isn't natively supported but that can be changed really quickly.
Go to TOOLS -> Extension Manager...
Click "Online Gallery"
Download AVRGCC C++ (Beta).
Since you're here, also download Terminal Window
. This is the serial monitor.
Click "restart now"4- Configure the programmerTHIS REQUIRES THAT YOU HAVE ARDUINO IDE ALREADY INSTALLED
Go to TOOLS -> External Tools...
Create the new tool with those settings:
Title: Serial Program
(Change that to match your arduino installation folder and locate avrdude.exe
Arguments: -CC:\arduino\hardware\tools\avr\etc\avrdude.conf -patmega328p -cstk500v1 -P\\.\COM3 -b57600 -Uflash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i
Check "close on exit"Change these parameters depending on the board you are using
Arduino Pro Mini:-patmega328p -cstk500v1 -P\\.\COM3 -b57600
Arduino Uno:-patmega328p -cstk500v1 -P\\.\COM3 -b115200
Arduino Mega2560:-patmega2560 -cstk500v2 -P\\.\COM3 -b115200
-p Name of the board
-c Name of the programmer
-b Baudrate of the programmerDon't forget to change the COM name of your serial port.
Coming from Arduino, you should know all of that, otherwise Find your serial port
, and google for the rest!5- You're done
To create a new project:
File -> New -> Project
Click on C++ Executable project, name it (No spaces or special characters
, otherwise AVRDUDE won't work), locate it and click ok.
Select your chip and click ok.
AVR Studio and WinAVR includes are the same, so you won't feel lost if you come from WinAVR6- Getting started
Attached is a sample Hello World project blinking a LED and printing on serial.
Download it, extract it, and open the "HelloWorld" AVR Studio 5 Solution File.
Open "HelloWorld.cpp" in the main tab.
Build the solution:Build -> Build Solution
Program your chip:Tools -> Serial Program
The Terminal Window should have opened with the project. If not, open it:View ->Terminal Window
Choose your COM port, baud 9600, ASCII, and click Connect
Click "OK" if an error message pops up, it is irrelevant.
This should work with the LED blinking, and your screen should look like the above screenshot!
"HELLO WORLD" should be printed every two seconds and the LED changing its state every 1s.Things to keep in mind:*When you run "Serial Program", run it while having in the main tab whatever is your "Main.cpp". (In this case, "HelloWorld.cpp")
Otherwise, AVRDUDE will try and program the chip with just the .hex file of whatever tab you were viewing (which won't work since there is no .hex file of that).
*If you're running the serial monitor, click "Disconnect" before trying to reprogram the chip.
*If you add a new .h or .cpp file, make sure it compiles:
In the solution explorer, click on the file, and just below in "properties", "Build Action", select "Compile"
Make sure that you have the right clock speed configured in your main file, just before "#include <util/delay.h>"
# define F_CPU 16000000L stands for 16MHz* The LED doesn't blink *
Check your ports* The serial doesn't work*
Open USART.H and change FOSC to match your cpu (same as F_CPU), and change BAUD to your liking. Just make sure to select the same Baudrate in the Terminal Window.
I hope this helped and made you want to switch to AVR Studio!
02/07/2012: Updated F_CPU and troubleshoot