SETTING UP AVR SOFTWARE



INTRODUCTION:

The Arduino environment is fairly simple. This in itself is a HUGE pain in the ass for complex projects. Modern day enviroments or (IDEs) have tons of great features that hey didn't have 5-10 years ago and a lot of the AVR guys tend to use AVR Studio or Programmers Notepad. Using these 2 environments does give us 1 big drawback. And that is that they do not take advantage of the Arudino Bootloader. The great news is that some smart people out there have figured out ways around this. Ways that I will teach you ... you dirty smelly human .... oh sorry ... too much portal 2.


SOFTWARE:

When it comes to AVR programming software, my drug of choice is the C language and AVR Studio, AVR Studio 5 has just come out in beta and is much more stable then AVR Studio 4 (which has been around forever). So lets begin should we?

Step 1: Download/Install (in order):

WinAVR

AVR Studio 5 or AVR Studio 4

xLoader

WinAVR is the C environment, unless you want to program in assembly your gonna need this.

AVR Studio is the IDE. If you have AVR WIN installed it will integrates itself into AVR Studios. I love it.

xLoader allows you to ... well upload .hex files (that AVR studio Generates) into the chip over thanks to the Arduino Bootloader. The bootloader is basically a small program that gets executed whenever you reset the AVR and, look for any incoming data streams that contains an AVR program.

Step 2: Verify that GCC is enabled:

Now when you start a new project you will have the option to create a AVR-GCC file. If this option comes up then your on the right track. If it doesn't it means that AVR-WIN didn't install properly, try rebooting before you reinstall.

AvrStudio5 - New Project

Figure 1: AVR Studio 5 Starting a AVR GCC project

AvrStudio4 - New Project

Figure 2: AVR Studio 4 Starting a AVR GCC project

Step 3: Setup Hex File Output:

Next you have to enable the .hex file output. This is not done by default so here are the steps.

AvrStudio5 - Hex File

Figure 3: AVR Studio 5 - Enable .hex file output

In AVR Studio 5, right clock on the project name in the Solution Explorer (right side) and select Edit Configuration Options, go to the Build tab (should be there by default), and make sure that .hex is checked.

AvrStudio4 - Hex File

Figure 4: AVR Studio 4 - Enable .hex file output

In AVR Studio 4 right-click on the project name in the left drop-down, then select Properties, and make sure that Create Hex File is checked.

Now whenever you hit F7 the project will be built and a hex file will be generated. The hex file will be located in the 'default' folder of the project.

Step 4: Uploading the .hex file:

Now, in order for the next step to work you have to have a Bootloader installed on your AVR. If you are using the Arduino kit it comes pre-installed, If however, you simply purchased an AVR chip from Digikey you will not have a bootloader installed. The good news is that Arduino Playground already has a simple tutorial on installing a bootloader. LINKY LINKY LINKY.

And here is something really kewl, Hexskrew over at the Arduino forums came up with a bootloader for the ATmega32L chip. The ATmega32L is the big brother of the ATmega8 and most of the ATmega8 code should work on it. Huge props to him for getting this working. UBER LINKY !!!

Now, if you wish to skip the bootloader and you have an AVR ISP you could just upload the file directly to the AVR. The advantage of doing so is that you save some memory (as the bootloader takes up about 1k mem) but the disadvantage is that you have to have an ISP programmer AND that you cant stream the hex file over wireless. Sparkfun has a great tutorial on the none bootloader way.

xloader - ATmega328

Figure 5: xLoader

The program is fairly simple, select the com port that your Arduino is on, Select your microcontroller (most arduino boards these days come with ATmega328 so select m328). Select right baud rate in case of ATmega328 it's 115200, so you have to edit the setting in the text box and hit Upload.

Step 5: Flashing AVR hex files over Xbee (wireless)

This is the kewlest tutorial that Sparkfun has ever done. My own writeup would just pale in comparison. LINKY LINKY LINKY!!!


Well that's it, short and sweet.

"They told me that I ought to stop making these pre-recorded messages, that gave me an idea, make more pre-recorded messages, I play the bills around here, I can talk about the control groups all dam day."
- Cave Johnson


Cheers
Q