Skip to content

Getting Started with AVR Studio

image In this article Jacob Woj continues with his getting started with Microcontroller projects theme. In the first article he compared the Arduino, Make Controller Kit, and more direct programming using AVR-GCC and an AVR-ISP for hobby microcontroller projects. This article focuses on the AVR Studio with WinAVR compiler with specific focus on how to do debug code using this tool set.

uCHobby requested that I do an article about debugging microcontroller code with AVR Studio. This article is meant for beginners (or people new to microcontrollers), as was the previous article. To start off you need an AVR Studio-compatible programmer, a target board or working microcontroller configuration, the WinAVR compiler, and AVR Studio 4. I will not venture into the chip configuration, as there are many other tutorials available on this subject, and there are so many different possibilities.

Install the WinAVR compiler first then AVR Studio using the supplied links. This is easy, just download the installer and accept the defaults.  Once these are installed follow the steps below.

-Start up AVR Studio. You should be greeted by this home-screen:


-Select the New Project Button

-Select the option to create an ‘AVR GCC’ program. If this option is not available, the WinAVR compiler is not installed correctly.

-It is a good idea to select the ‘Create folder’ option, as more than one project in a folder is a pain to organize and maintain (projects will be over writing each other due to common filenames used). Enter the name of your project and hit next.



-Next, we are presented with a choice in the debugging platform. Because it is assumed that we are using an ISP programmer, we cannot do the debugging on it. Select AVR Simulator instead. One that is done, select you chip, and hit finish.


-The program that I wrote is a little bit useless, but was written to demonstrate debugging in the studio. It is as follows:

#include <avr/io.h>

int main(void) {

  DDRB = 0xff;

  PORTB = 0b00000011;

  PORTB = 0b00001111;

  PORTB = 0b00111111;

  PORTB = 0xff;



-Once you have that entered hit the ‘Build Active Configuration’ button, or just press F7.


-When you see a success message at the bottom of the screen, open the debug menu and press ‘Start Debugging’.



-You will then see a yellow arrow one step above where the program is. Do not mind it for now.

-In the IO View panel, select PORTB:


In the window directly underneath will be bit diagrams for DDRB, PINB, and PORTB. DDRB just shows which pins in PORTB are active. PINB is always one step behind PORTB.

-To toggle through steps, Press F11, and you will see the bits changing in the diagrams. The changes should correspond with what you envisioned to happen in the line above the arrow. If they do not, you have found your first ‘bug’ in the debugging process.


-To add a breakpoint (a point where the program should stop running), click at the end of a line and click on the red dot button, or hit F9.


The button beside it will remove all breakpoints, and allow you to run the entire program.

-To program your chip or board, you must then select your programmer from the ‘Connect Dialog’ box.


-Hit ‘connect’ once settings are correct.

-Beside the connect button is the button for programming. When it is hit, you get the options for how you would like to program your chip. Once you are done, hit the Program Tab, select your compiled HEX file, and hit ‘Program’ at the bottom of the page.

There yo
u have it; you have now debugged and programmed a chip using AVR Studio 4.

Posted in Development Tools, Discovering, Electronics Links, Microcontroller, Projects.

Tagged with , , , , .

One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Continuing the Discussion

  1. AVR Dragon’s at uCHobby | uC Hobby linked to this post on January 8, 2009

    […] Studio. His first article compared the various microcontroller options available for hobbyist. The second article described setting up for development with the free AVR Studio and AVR-GCC compilers to do […]