Microcontroller - A Beginners Guide - Installing the Atmel Studio 6 Development System
WinAVR and the AVR-GCC programming environment and compiler is not the only environments out there. The Atmel Studio 6 is a
development environment that uses Visual Studio as its backbone. The Atmel Studio 6 is the official development environment
for the AVR line of microcontrollers and can be used with the ARM Cortex controllers developed by Atmel. The Atmel Studio 6
is a feature rich environment that contains all of the tools to program, debug and simulate all aspects of the
microcontrollers. In this section, you will learn how to install Atmel Studio 6 and configure it to program microcontrollers
using the USBTiny specifically, but any programmer can be chose and configured using these steps.
It's easy to find information about Atmel Studio 6 and the installation download just by searching for "Atmel Studio" from
google. The instructions on the Atmel site is straightforward but requires you to go through a registration process.
Atmel Studio features the ability to program the controllers as its default state, but the USBTiny is not included in the list
of programmers, so this is an aspect of configuring the software that is not so straightforward; hense, the reason I created
this video.
Since the USBTiny uses AVRDude to program the microcontroller, Atmel Studio has a feature called External Tools that we can use
to invoke the ARVDude.exe. The External Tools dialog box under the Tools menu contains the fields that allow us to run an
external program and add command line arguments (like the programmer we will use, the microcontroller part number, the hex file
to be transfered to the microcontroller, etc.).
The fields that the external tools dialog box contains is the Title, which will be shown under the tools menu for quick
execution, a command field for the the program we will execute (ARDude.exe), the arguments field to contain all of the command
line parameters, and a field that we will not use called the initial directory.
There are Macros that are used to point to specific places on the computer, but be forewarned, not all of the macros work as
you will see in the video. So lets go through each field and determine what is needed:
Command: This field will only contain avrdude.exe
Arguments: This field will contain any of the parameters that can be used with avrdude. You can use avrdude.exe to see a list
of just by entering avrdude.exe at the dos prompt (start, run, cmd.exe) and a list of the parameters will be listed.
We will use the -c for the programmer name, -p for the microcontroller part number and -U telling arvdude to put something
into the microcontroller's memory. For example:
-c usbtiny -p m644 -U flash:w:$(ProjectDir)Release\$(ItemFileName).hex:i
will program the ATMega 644 or 644A using the USBTiny programmer and transfer the .hex file that is located in the ProjectDir
under the Release sub directory that shares the name with the name you gave the project. The $(ProjectDir) and $(ItemFileName)
are macros. The ProjectDir macro will have a trailing backslash which separates the sub folder of Released. The :i is telling
AVRDude that the .hex file is in the format of Intel Hex.
You can make external tools for various microcontrollers and various programmers and using the Debug folder rather than the
Release folder. Be careful to program the microcontroller using the same Debug or Release state from which the program was
built, otherwise, you will get en error in the output window stating that the file was not found. Fortunately, the information
in the output window is verbose and you will know exactly what is going on.
The procedure from starting the Studio to getting the final compiled program on the microcontroller is as follows:
-
Start the Atmel Studio by clicking start, all programs and clicking on the Atmel folder and clicking on Atmel Studio 6.
-
Start a new project by either clicking on new project from the start screen, or by clicking on file -> new -> project.
-
Name the new project and click OK/
-
Select the microcontroller you will be using (use the pull down menu at the top to filter the main microcontroller family
categories. When you click on a microcontroller, you will see some option on the right that includes a list of programmers
and the datasheet of the microcontroller. This will come in handy when you start programming as there may be a need to
open the datasheet for convenient use while programming. If you did not open the datasheet at this point, you can just
click on the name of the part at the top right of the environment and it will present the same options for you to use.
-
Write your program, making sure you select the correct state (Release or Debug).
-
Build (compile) the program: click Build at the top menu and then clicking the build option that includes the name of the
project. Assuming there are no errors in the program, this process will create a .hex file in the Release or Debug sub
directory under the project directory.
-
Finally, you will use the external tool that was created which should be shown under the tools menu just above the External
tools... option.
Commenter Matthew Humphrey state that the following can also work and has the added benefit of using the current state (Release or Debug).
-c usbtiny -p m644 -U flash:w:$(TargetDir)$(TargetName).hex:i