Lab 2: AVR Programming

Assigned: Wednesday, October 5

The goal of this lab is to become familiar with the ins and outs of programming on the AVR mini.

0. Set up your environment to use the AVR

a. Follow OS specific instructions for installing the AVR environment

planetCCRMA@ccrma : planetCCRMA@home : linux : mac : windows

b. Make, in your home directory make a 250a/labs directory.

~> _
~> mkdir 250a
~/250a> cd 250a
~/250a> mkdir labs
~> _

c. download the lab2 demo files into the labs directory.

~/250a/labs> gunzip lab2.tar.gz
~/250a/labs> tar -xvf lab2.tar

d. Set up AVRmini connection to PC

Connect power cable, connect serial cable to right hand port, and power-up the AVRmini

d. Test AVR setup with "flash" test code

(windows users using an IDE like AVRStudio rather than the Unix like Cygwin approach, will need to eek out your own method of compiling and loading with that IDE).

In the

lab2/flash
folder, compile and download the code to the AVRmini: Press the RESET button on the AVRmini and within 2 seconds type:

make load

You should see a sort of makeshift progress bar as a bunch of "#" characters print in the terminal window. If the program transferred successfully, then press RESET again.

Make sure that one end of the ribbon cable is attached to PBLED and the other to PORTB

If everything is working, a LED on the AVRmini board should start flashing.

1. AVRMini Input/Output

a. Review architecture and programming, as necessary (all of these references are availible on the resources page)

b. Momentary pushbutton

Optional: Toggle pushbutton using debounce.

c. Four buttons:

d. Beep:

3. Compile, Run and Play the AVRsimon: