This post describes how to use ATMEL Studio 6 instead of the Arduino IDE to build applications. It presumes a certain level of knowledge and experience.
EDIT : Ive updated this post to refer to Atmel Studio 6 instead of AVR Studio 5, so many of the posts below should be read with that in mind ( ie problems with 5.0)
On his excellent website, Smiley http://www.smileymicros.com tries to persuade us to leave behind the Arduino libraries, the vast numbers of samples, and to convert to a "better way". (Hope Im not misquoting him!) While I see some advantages in this approach, in my case I had already half developed some applications and I didn't want to start again.
So I could stick with the Arduino IDE, but it was driving me crazy. A great way to start: copy and paste some example code into my "sketch", press upload and then bingo, the LED fashes. But Ive grown to dislike it. Its slow. It has no intellisense. The IDE sucks. I disliked the extra pass it makes to change my code in strange ways. (Thats fixed now though). There's no debugger. There are other things i dislike but they are of a petty nature; the first five are enough. So I went looking for alternatives, and came to think there are two, Eclipse or Visual Studio (ATMEL Studio 6 to be precise).
First off those that like Eclipse have it sorted I believe. You can read how to use Eclipse for Arduino here: http://arduino.cc/forum/index.ph... Ive used Eclipse to write code for my wifes Android phone "“ its pretty good. If you want cross platform, thats an obvious winner. But Ive been writing C++ with Visual Studio for longer than I care to admit (been in computing since 1973, which would trump most of the readers of this forum I would think), and for me, Visual Studio and Visual Assist is a winning combination (Visual Assist is great but not free). So I wanted to use VS. I went down a lot of tangents because Google led me to a lot of information that is no longer relevant. I had to especially make sure I didn't bother too much reading about WinAVR AVRStudio 5 or anything related to AVRStudio4. I havent used VisualMicro recently but I cant see the need for it.
My original post decribed AVR Studio 5 and how to use it. But there were annoying bugs, these have been fixed in version 6.
ATMEL Studio 6 is a winner.
When AVR Studio 5 got launched it looked to be perfect for me. BUT, it didn't support C++ all that well. They've fixed that now ( very recently) "“just install the C++ Extension which as of August 2011 is a beta release. Installation is through AVR Studio 5 Tools menu:
Tools -> Extension Manager -> Online Gallery -> AVRGCC CPP(Beta)
Ive found two minor bugs "“ more on that later.
The biggest challenge was to work out how to use the core Arduino libraries. You need to tell it where to find the headers, and setting the directories was easy enough. I had originally installed the Arduino IDE(version 22) to C:\arduino, so I just added C:\arduino\hardware\arduino\cores\arduino to my directories for the C++ compiler (Properties of the solution/ Toolchain). While I was at it, I added the folder for each of the libraries I wanted to use. To start off, I took a copy of the main source file with the PDE extension and gave it a CPP extension).
Almost there, but getting it to link proved harder.
Now when you use the Arduino IDE it builds a library from all the core source code "“ eg the code for Serial. This library gets built each time ( did I mention that I dislike how slow it is), and squirrels it away into a funny place that is difficult to find.(look for a folder with a name like C:\Users\fred\AppData\Local\Temp\build5690015305384173079.tmp) I grabbed a copy of it from there so I could use it as part of my VS project. Its name is libcore.a and I copied it to a place where all my projects live C:\Users\fred\Documents\Arduino
I then went to the "Toolchain\AVR/GNU C++ Linker\Miscellaneous" tab and added this
In version 5, one had to tweak the makefile to get past linker errors, but thankfully that is a thing of the past.
Now after adding this one line:
Serial.println("Start of loop");
Soooo close now.
The next thing is to get the program onto my hardware (Arduino UNO). I defined an external tool:
Arguments: -CC:\arduino\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P\\.\COM3 -b115200 -D -Uflash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i
I got this command from a verbose output from the Arduino IDE. But wow, I don't know why so many ""“v"options, where did they come from and what are they for? Anyway, it works, and so I made a button to do the upload and now its a simple click.
Finally I got nifty with the source code, so I can still compile things in the Arduino IDE if I really want to. ( Basically I gutted the source file with the PDE suffix and put everything in other source files)
In summary, was this worth the effort? Quite honestly, yes it was. My new environment is much faster and much more productive. The niggly problems got sorted by the AVR team - thanks - and now I have the best of both worlds.
This gives you a quick overview "“ Ive left out an awful lot of detail. And since this original post, others have described the process in more detail - eg http://www.jayconsystems.com/tut...
Suffice to say it is well worth doing.
[this is great stuff so I made it into a permanent tutorial - moderator]