by Joe Pardue
PART 2: Your First AVR Program
C’ing With Cylon Eyes
Get started now with this
series! Joe’s book & kit are
available in our webstore at
www.nutsvolts.com
This workshop is the second of a series that will
introduce C programming for the AVR microcontroller
based on the book C Programming for Microcontrollers
Lby Joe Pardue available from www.smileymicros.com
ast month, we learned where to get the
software and hardware we’ll need, built the or Nuts & Volts ( www.nutsvolts.com).
AVR Butterfly-based AVR Learning Platform, and
tested it with Developer Terminal. This month, we will
write and compile our first C program using our AVR
Learning Platform. This is not
■ FIGURE 1. Cylon. going to be the standard
wimpy ‘Hello World!” of yore,
but a zippy software/hardware
combination where we create
some Cylon eyes. These
aren’t eyes of the cute, sexy ■ FIGURE 3. Welcome to AVR Studio 4.
Cylons of the recent Battlestar
Galactica, but the old
fashioned ‘70s walking chrome
toaster Cylons of the original
series.
Setting Up the Project
Configuration Options
From the ‘Project’ menu item, select ‘Configuration
Options’ (Figure 5).
In the ‘Project Options’ window, select the
ATmega169 from the ‘Device:’ dropdown box (Figure 6).
Getting Started With Free Stuff:
AVR Studio and WinAVR
AVR Studio provides an IDE for writing, debugging,
and simulating programs. We will use the WinAVR GCC
C compiler toolset with AVR Studio via a plug-in module.
You can find these at AVRStudio ( http://atmel.com/
dyn/products/ tools_card.asp?tool_id=2725) or WinAVR
( http://sourceforge.net/projects/winavr/).
Install WinAVR first and AVR Studio second (use the
default locations so AVRStudio can find WinAVR).
Click on the AVR Studio desktop
icon (Figure 2). It opens with ‘Welcome
to AVR Studio 4’ (Figure 3). Click on
the ‘New Project’ button.
In the ‘Create new project’ window
(Figure 4), click on AVR GCC, add the
‘Project name’: ‘CylonEyes,’ and set the
‘Location’ to a convenient spot. Then click finish.
The IDE is somewhat complex, with lots of tools
that we won’t be using just yet, so try not to have heart
palpitations. It will mostly make sense eventually.
■ FIGURE 4. Create New Project.
■ FIGURE 2.
September 2008 55