Atmel Studio 6
Development Environment Setup
Atmel Studio 6 is (was) the official tool for programming AVR chips. It runs on Windows only. If you ask me, compared to Eclipse, I find the interface unintuitive and awkward. However it works just fine and it is much easier to install, basically ready right out of the box. That is, until you try to use the Pocket Programmer as a download tool instead of an approved Atmel tool, but I'll give you the trick to make that work.
The version and links have short shelf time and might become obsolete, but the general procedure should remain valid.
Download and Install Atmel Studio 6
Here is the link from the Atmel site:
http://www.atmel.com/tools/atmelstudio.aspx
It's free but it will ask you for your e-mail and verification before you can download it. Here is a less annoying direct link instead, but it might go obsolete at some point:
www.atmel.com/Images/as6installer-6.0.1703-full.exe
Setup a new project for the MarcDuino board
Go to File->New project, and select GCC C executable project.
Give it a name. I am not sure what this new business is about "Solutions" (that didn't exist in Studio 5) towards the bottom, so I left the choice as "Create new solution" and gave it the same name as the project. Go figure.
When you click OK, it prompts you for the hardware target, select ATmega328p
The project will appear in a window called "Solution Explorer". Studio 6 tries to help too much and creates some questionable automatic code. Right click and delete the file .c file it created (called here MarcDuino_Panels.c):
Now right-Click on the project file, choose Add->Existing Item. Add the MarcDuino source files which you can download from this page:
Define the F_CPU project variable
Your project is almost ready to compile. However, if you compiled now, it would complain about a missing F_CPU symbol. You have to define it for the project:
Go to Project properties > Toolchain > Symbols
In Configurations, select All Configurations (don't miss that step, or it will only do it for the Debug config!)
In Defined Symbol, click on the green arrow and add the following entry, defining our clock frequency at 16 MHz:
F_CPU=16000000UL
Build your project
Go to Build->Configuration Manger, select "Release"
Save the project. Now it choose Build->Build Solution
It will now compile the source code, ending with some console output like this:
Done building target "CoreBuild" in project "MarcDuino_Panels.cproj".
Target "PostBuildEvent" skipped, due to false condition; ('$(PostBuildEvent)' != '') was evaluated as ('' != '').
Target "Build" in file "C:\Program Files\Atmel\Atmel Studio 6.0\Vs\Avr.common.targets" from project "C:\Documents and Settings\Marc\My Documents\Atmel Studio\MarcDuino_Panels
\MarcDuino_Panels\MarcDuino_Panels.cproj" (entry point):
Done building target "Build" in project "MarcDuino_Panels.cproj".
Done building project "MarcDuino_Panels.cproj".
Build succeeded.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
Upload the code to the MarcDuino board
One of the annoyances of Studio 6 is that it only supports upload tools from Atmel, which is one of many reasons why I don't like to use it. To upload using the recommended AVR Pocket Programmer, you need to set the Fuses with AVRDude from outside Studio 6 following the method outlined here:
Once that's done, and assuming you have downloaded AVRDude, you can setup an ugly workaround to use the Pocket Programmer as an external tool.
Go to Tools, External Tools, Add
For command, navigate to your AVRdude.exe file (I downloaded mine as part of WinAVR, where it sits in the /bin folder)
For arguments, use
-c usbtiny -p m328p -U flash:w:Release\MarcDuino_Panels.hex:i (replace with the name of your .hex file)
For initial directory
$(ProjectDir)
Click Use Output Window
Once you click OK, the option USBTiny appears in the Tool menu, clicking it will upload your .hex file.