Atmel released the new version of their well-known Avr Studio, which now combines AVR, ARM and Qtouch under a new name: Atmel Studio

Official Atmel Studio 6 page

For the AVR part, the main difference with AVR Studio 5 is that C++ is now fully supported!
It still comes with great and convenient development tools, advanced debugger and simulator, and 1000 examples written by professionals!

They also got rid of the annoying Terminal Window error message.


Step by step, this tutorial will help you set Atmel Studio for your Arduino boards!

Step 1: Download Atmel Studio 6

First option: through registration

Go to www.atmel.com/tools/atmelstudio6.aspx and select the desired installer at the bottom of the page.

Then follow the instructions (register) to download the Atmel Studio 6 Installer.

Second option: without registration

Here are the direct download links for Atmel Studio 6:

www.atmel.com/Images/as6installer-6.0.1703-small.exe
www.atmel.com/Images/as6installer-6.0.1703-full.exe

Note: Those are the current download links, and might be outdated in the future as new revisions come out, and there might be a delay until I update the links in this tutorial. To have the latest version, use the registration way.

Step 2: Install Atmel Studio 6

Well, there isn't anything complicated here. Run the installer you just downloaded, and follow the steps, install what is needed and wait until the installation process is finished!

Step 3: Launch Atmel Studio 6

Easy step, right?

Step 4: Download the Terminal Window Extension

The Terminal Window Extension in Atmel Studio 6 is the equivalent of the Arduino Serial Monitor.
Go to Tools -> Extension Manager...
Select Online Gallery and Download Terminal Window
Once installed, restart Atmel Studio 6 as prompted.

The Terminal Window can now be found in View -> Terminal Window


Step 5A: Configure the Arduino programming tools (Use this method to program your Arduino using the bootloader with USB to Serial Converter)

This requires that you have Arduino IDE already installed

Go to Tools -> External Tools...

Create the new tool with these settings:

  • Title: Serial Program
  • Command: C:\arduino-1.0.1\hardware\tools\avr\bin\avrdude.exe

(Change that to match your arduino installation folder and locate avrdude.exe)

  • -CC:\arduino-1.0.1\hardware\tools\avr\etc\avrdude.conf -patmega328p -carduino -P\\.\COM3 -b57600 -Uflash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i

Change these parameters depending on the board you are using:

Arduino Pro Mini:
-patmega328p -carduino -P.COM3 -b57600

Arduino Uno:
-patmega328p -carduino -P.COM3 -b115200

Arduino Duemilanove:
-patmega328p -carduino -P.COM3 -b57600

Arduino Mega2560:
-patmega2560 -cwiring -P.COM3 -b115200


Note: If your directory paths contain spaces (like in "Program Files (x86)"), you might need to input the whole paths between quotation marks. Example: -C"C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf"

Updated on June 10th, thanks to user feedback. Updated Mega2560 command line on September 15th, thanks to user feedback. Updated directory paths note on Nov 28th, 2013, thanks to user feedback.


-p Name of the board
-c Name of the programmer
-b Baudrate of the programmer

Don'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!

  • Check "close on exit" and hit OK

Step 5B: Configure the Arduino programming tools (Use this method with an external programmer Ex: USBTiny AVR Programmer)

 

This requires that you have avrdude already installed.  You can download it by clicking here.  Download and extract it to your AtmelStudio working directory.


Initial setup, Burining Fuses (you will need to create a new external tool and flash the chip).  

In order to begin programming your arduino, you will need to do an initial flash of the fuses on the AVR.  This only needs to be done once, unless you like tweaking with settings and want to get the most out of your hardware. 

Warning: Setting the fuses incorrectly CAN, AND WILL LOCK YOU OUT OF YOUR AVR PERMANENTLY!  Before even considering changing the fuse settings, you must know what your current settings are, and what they mean.  That means going to the datasheet for the chip, and finding a fuse calculator to help (I use this:http://www.engbedded.com/cgi-bin/fcx.cgi?P_PREV=&P=ATmega328P).


Go to Tools -> External Tools...

Create the new tool with these settings:

  • Title: Fuse Flash
  • command: C:\Users\<user>\Documents\Atmel Studio\avrdude-5.11-Patch7610-win32\avrdude.exe    (change to match your own directories)
  • arguments: -c usbtiny -p atmega328p -F -i 25 -s -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xFD:m    (copy and paste)

Select "Use Output window".  This allows you to see what avrdude is doing and if any errors occur.  If an error does occur while uploading fuse settings, the chance that you turned your arduino into a paperweight is high.  

 

Connecting to your AVR/Arduino
You will be connecting the programmer to your AVR over the SPI pins. Unlike RS232, there isn't a need to match TX with RX and vice versa.  MOSI goes to MOSI, CLK goes to CLK, so on and so forth. If you are looking at your programmer and don't know which pin is what, flip it over. For this tutorial we are going to use an Arduino Mini. If you are using the USBTiny, the pinout for the programmer should be on the back of the board. Note that there are 10 pins on the Programmer, but only 6 are required for programming. For the Ground pin, you can use any of the four labeled GND.



To power the arduino, you have two options if you are using a USBTiny Avr Programmer:

  1. If the arduino board is in a circuit or otherwise disposed, use whatever power you have supplying the arduino.  The slider switch should be set to "no power" on the programmer.
  2.  If the arduino is standalone, you can use the supplied power via usb. 


Note: If the Stat1 LED is off, you will need to reset the programmer by cycling the power (unplug usb cable).

WARNING: Ensure solid connections before programming!  Insecure connections can cause communication errors and kill your arduino!  Yes, emphasis is needed.

Running the Fuse Burning Tool
Once the tool is created, all that you must do is go to Tools > Fuse Flash.  Clicking Fuse Flash will initiate flashing of the fuses and the chip should be ready for programming.

 

Create the new tool for programming with these settings

  • Tools > External Tools > Add
  • Title: AVR Program
  • command: C:\Users\<user>\Documents\Atmel Studio\avrdude-5.11-Patch7610-win32\avrdude.exe (change to match your own directories)
  • arguments: -c usbtiny -p atmega328p -F -U flash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i   (copy and paste)

Select "Use Output window".  This allows you to see what avrdude is doing and if any errors occur.

Running the Programming Tool (after your project has compiled and a FileName.hex file has been generated)
Once the tool is created, all that you must do is go to Tools > AVR Program.  Clicking AVR Program will initiate uploading of code in your current project.


Step 6: You're done

To create a new project:
File -> New -> Project
Click on GCC C++ Executable Project, name it (No spaces or special characters, otherwise AVRDUDE won't work), locate it and click ok.
Select your chip (most likely Atmega328p for Arduino boards) and click ok.

Step 7A: Getting Started

Here is an example project I wrote to get you started. It will blink the onboard LED and print HELLO WORLD on serial.

Download link

Download it, extract it, and open the Hello World ATMEL Studio 6.0 Solution File

  • Open HelloWorld.cpp in the main tab.
  • Build the solution:
    Build -> Build Solution
  • Program your chip:
    Tools -> Serial Program
  • Open the Terminal Window
    View -> Terminal Window
    Choose your COM port, baud 9600, ASCII, and click Connect

This should work with the LED blinking, and your screen should look like the screenshot below!

Step 7B: 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 Terminal Window, 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"