2.5. Atmel Studio

What is an IDE (Integrated Development Environment)?

An IDE is a software application that typically integrates a source code editor, build automation tools and debuggers, but can provide other tools as well (such as interpreters, code analysis tools etc.). Their user interfaces are designed to maximize the programmer’s productivity and help in the developing stage of applications.

Why Atmel Studio?

Atmel Studio 6 is the IDE for developing and debugging Atmel ARM® Cortex™-M processor-based and Atmel AVR® microcontroller applications [1]. It is free for download on the Atmel official website, it includes a GNU C/C++ Compiler and it offers support for over 300 Atmel AVR and SAM3, SAM4 devices. Moreover, it offers a vast source code library and over 1100 project examples.

Installing Atmel Studio 6

  1. Download the installer from the official website (you may have to register): http://www.atmel.com/microsite/atmel_studio6/default.aspx
  2. Double click on the installer. If Windows asks you if you want to run the file, select “Run”.
  3. Run the installer from the location on your computer, and follow the instructions on screen.

You can also watch the video at Resource 1 for more information.

Installing Pololu Drivers [2]

  1. Download and install the Pololu AVR Development Bundle from the official website: http://www.pololu.com/file-redirect/avr-development-bundle
  2. Run the installer. During the installation, Windows will warn you that the drivers have not been tested by Microsoft and recommend that you stop the installation. Click “Install this driver software anyway” (Windows 7 or Vista).
  3. When you run the Pololu AVR Development Bundle installer, it will ask you which components to install. It is OK to install them all.
  4. The installer for the Pololu AVR C/C++ Library will ask you which AVR toolchains you want the library to be installed into. Choose Atmel Studio 6 and select “Install”.
    • If the Atmel Studio 6.0 checkbox is grayed out, then the installer was unable to find Atmel Studio 6.0 and you should try reinstalling or repairing it.
  5. If you use Windows Vista or Windows 7, your computer should automatically install the necessary drivers when you connect a programmer.

What is a normal flow in embedded software development?

  1. Creating a project and adding files to it. In this phase you will write the necessary code and add different resources to your project.
  2. Build the project. This step translates the high-level code written into a code understood by the microprocessor. On a PC, this generates the executable (.exe) file that you can use to run your program. Usually, on your embedded device this is the .hex file (but there are also other formats, such as .elf, .map, .eeprom). You can read more about .hex files at Resource 2.
    • If you have errors in your code at this level you will receive a compiler error. The .hex file will not be generated until you fix these errors, but the IDE will help you by pointing out the line in the code where the error is and an error message.
  3. Upload the .hex file on the microcontroller.
  4. Debugging. If the code doesn’t work like you would expect it to, you have runtime errors. These are harder to find and fix than compiler errors, but Atmel Studio 6 helps you by providing a simulator and different debugging tools. After modifying your code accordingly you have to start over from Step 2.

Creating a New C Project for GCC in Atmel Studio 6

  1. On the left side of the Start page select “New project”.
  2. In the New Project dialog, select Installed Templates. There should be a C category there; if there is no C category, make sure that you have installed the Pololu AVR C/C++ Library and try restarting Atmel Studio 6. Expand the C category, and select Pololu to see a list of templates that were installed by the Pololu AVR C/C++ Library’s installer. Select the “3pi Robot with Atmega328P” template. You can also change the name of the application and the location where it will keep the solution files.
  3. After you click “OK”, Atmel Studio will create a new project from the template and open it. The project will contain some simple example code that demonstrates basic features of the board, such as blinking an LED, playing some notes on the buzzer, and displaying numbers on the LCD. The functions being called are defined in the Pololu AVR C/C++ Library. You can find more information about them in the Pololu AVR C/C++ Library User’s Guide and read their source code by looking in the directory where you installed the library.

Notice that on the right of the IDE there is a Solution Explorer that shows you all the files in your project. For more information about creating a project, watch the video at Resource 3.

Building a Project in Atmel Studio 6

  1. Once the project is set up, you can try and build it by selecting “Build”→”Build Solution” or by pressing F7.
  2. In the “Output” window in the lower part of the IDE you will see the results:
    • The build progress and where your output files are stored if the build is a success OR
    • The compiler errors if the build failed.

This is more thoroughly explained in the video at Resource 5.

Debugging AVR Applications with Atmel Studio 6

  • To start debugging, click the “Start debugging and break” button in the user interface (or press Alt+F5).
  • When debugging, the output window is replaced by a collection of debug-specific windows, such as the “Watch” window and the “Breakpoints” window.
  • The Solution Explorer tab also gets replaced by a “Processor” tab which shows the state of key registers.
  • Adding a watch: right click on any variable and select “Add watch”. This will show the value the variable has throughout the execution of the program in the “Watch” window.
  • Stepping through code: if we are not interested in a particular function, we can “Step Over” it (press F10 or select the button in the IDE). This will run the code in the background and highlight in the editor the line that it is currently executing.
  • Set breakpoints: right click on any line in the editor and select “Breakpoint”→”Insert Breakpoint”. When you run the program it executes normally and halts when it reaches the breakpoint. If you have placed a breakpoint on a function call, you can now press the “Step Into” button (or press F11).
  • By combining these actions you can explore:
    • The variables you have defined (in the “Watch” window).
    • The registers used by your application (in the “Processor” tab).

More information about debugging can be found in the videos from Resources 6 and 7.

Programming the microcontroller

  • In-System Programming is the ability of some programmable logic devices, microcontrollers, and other programmable electronic chips to be programmed while installed in a complete system, rather than requiring the chip to be programmed prior to installing it into the system [3]. In order to program a microcontroller on a board you must first connect it to an In-System Programmer (ISP).
  • The ISP connects to the microcontroller’s board at one end (through the 6-pin connector) and to the computer on the other (USB port).
  • Before programming, make sure your device is powered.
  • To program, simply press the F5 key.
  • If programming fails: If you get an error message after attempting to program, then click “View” → “Available Atmel Tools” to open the “Available Tools” window. Make sure that there is one and only one STK500 in the list and make sure that the COM port number matches the COM port number of your programmer’s programming port, which is displayed in the Device Manager.
  • If the programming was successful, you should be able to see the program running on your device.

The video from Resource 8 will walk you through the key steps of programming a microcontroller.


  1. Installing Windows Drivers and Software for the Pololu USB AVR Programmer: http://www.pololu.com/docs/0J36/3.a
  2. Pololu USB AVR Programmer User’s Guide – Getting started with Windows: http://www.pololu.com/docs/0J36/3


  1. Downloading and installing Atmel Studio 6: http://www.youtube.com/watch?v=qbwmlZgaLGI&feature=plcp
  2. Create a New C Project for GCC in Atmel Studio 6: http://www.youtube.com/watch?v=_ADg1cIWRWg&feature=plcp
  3. Build a Project in Atmel Studio 6: http://www.youtube.com/watch?v=rGvYALiO4fQ&feature=plcp
  4. Debugging AVR Applications with Atmel Studio 6: http://www.youtube.com/watch?v=aAw-7Lq-3tI&feature=plcp
  5. Using the Simulator in Atmel Studio 6: http://www.youtube.com/watch?v=9QlDSNeuAdY&feature=plcp
  6. In-System Programming in Atmel Studio 6: http://www.youtube.com/watch?v=MRyzNZ7wevA&feature=plcp
roboticsisfun/chapter2/ch2_5_atmel_studio.txt · Last modified: 2012/10/28 19:45 by liana.marinescu