Getting your computer (and you) set up
For the linux folks
You will need to find and install rpms for your distribution for:
- avrdude (you may have to download the source and compile this one yourself)
Creating and compiling your program
- Create your C program (start with this sample program:
led_flash.c). You may use the
Programmer's Notepad from WinAVR if you wish (but it is
- Create a makefile (start with this sample
- Modify the makefile so that it points to your source file:
Change the TARGET = led_flash.c line so that it
contains the name of your source file.
- Compile the your program:
- From the windoze menu, select: "run" and then type "cmd"
- Use the "cd" command to change directory to the location
of your makefile and source file.
- Type make. If there are no errors in your
program, you will have a variety of files, including:
- led_flash.lst: a file
that shows both your program and the
corresponding assembly code
- led_flash.hex: a file that contains the program
information that will be downloaded to your
A Basic Circuit
You may use the original led_flash2.fig
file if you wish (this is an xfig file).
The key components are:
- The Atmel Mega8: your microcontroller. Note the power and
- The AVR ISP Connector: connects the processor to the programmer.
- L1 and L2: LEDs used in the sample program. Note that the
polarity of the LEDs is critical. Also - you need a resistor
in series with each of the LEDs (200 ohms will do).
- LC is a status LED that allows you to see when the programmer
is downloading code to your processor. This LED is useful, but
- The crystal and 15 pF capacitors connected to pins 9 and 10 are
necessary if you want your processor to be clocked at 16 MHz
(by default the processors use an internal clock that runs at 1
- The 10K ohm resistor on the reset line (pin 1) keeps the line
high so that the processor will not reset (unless commanded by
the AVR ISP programmer).
Downloading Your Program
- Connect your AVR ISP to your circuit (as shown above). Make
sure that you do not reverse the orientation of the connector
- Apply power to your circuit
- From your program directory, type: make program
- Once your the download is complete, your processor will be
- It is always a good idea to flash an LED in some unique way
at the beginning of your program. This way, you can be sure
that your processor is receiving power and that the power
supply is stable.
- For delay_us() implementation, see: delay_us_test.c
fagg [[at]] cs.ou.edu
Last modified: Mon Apr 11 16:54:31 2005