AVR

From CCRMA Wiki
Revision as of 16:04, 20 February 2007 by Gurevich (Talk | contribs) (Mac OS X)

Jump to: navigation, search

AVR Microcontrollers

AVR 8-bit RISC microcontrollers by Atmel are currently at the heart of the embedded technology platform we use in Physical Interaction Design research and courses at CCRMA. These chips have a modern Harvard Architecture, executing most instruction cycles in a single clock cycle. An extremely efficient open source C compiler is available, and these devices are used and supported by a large community of developers. The AVR architecture and instruction set is available in a large family of 8-bit devices that come in a variety of packages. AVR-series chips come with as little as 1 Kbyte of Flash program memory, up to 256 Kbytes; 32 bytes to 8 Kbytes of RAM; and up to 20 MHz clock speeds. Specialized AVR devices exist for automotive, LCD and lighting control, USB and radio applications. Code is easily portable between devices.

AVR Hardware at CCRMA

ATMega32

We currently use the ATMega 32 (Product Page). It features:

  • 32 Kbyte self-programming Flash Program Memory
  • 2 Kbyte SRAM
  • 1 Kbyte EEPROM
  • 8-Channel 10-bit A/D-converter
  • Up to 16 Mhz clock
  • I2C, SPI interfaces
  • 1 USART, 2-channels PWM, 2 ext. interrupts

ATMega 32 Documentation:

AVRmini Development Board

The AVRmini development board, made by Pascal Stang, is a general purpose prototyping board that provides easy access to the AVR's I/O and programming interfaces, along with a number of useful peripheral devices. We are currently using the AVRmini v4.0. The AVRmini v4.0 provides:

  • Support for most 40-pin AVR processors
  • Ethernet, USB, SD/MMC, RS-232 I/O
  • I2C header
  • Character LCD header
  • 10-pin I/O headers
  • 4 buttons and 4 LEDs
  • 5-V regulator

AVRmini Documentation:

CCRMA's AVR Prototyping Kit

For our PID courses at CCRMA, we assemble a prototyping kit based on the AVRmini. We mount the AVRmini on a sheet of 1/8" acrylic, and add solderless breadboard strips, an LCD display and a small loudspeaker. Pins 9 and 10 of the AVRmini v4.0's "AUX" header (JP13) are connected to the ground and +5V power rails of the breadboard strips.

  • kit Photo

Spyglass User Interface Board

The LCD display on CCRMA's prototyping board is part of the Spyglass User interface Board, which communicates with the AVR via I2C. We purchased these on eBay, and from a few other places, but they are hard to come by these days. Pascal Stang has written a brief Spyglass User Guide. He has also developed a replacement I2C button module/LCD driver (no documentation available) to which we can connect an LCD display and use just like the Spyglass.

  • Spyglass photo
  • buttonmodule photo


AVR Software at CCRMA

AVRLib

avr-gcc

Setting up your Computer to do AVRLib / CCRMA-Style AVR Development

Linux Machines at CCRMA

The Linux machines at CCRMA already have the AVR development tools installed, and in your path. All you need to do is get a copy of the AVRlib. The avrlib-demos are helpful in getting started.

AVRlib

To get the most up-to-date version, use subversion. In a terminal, change into your home directory, and then type:

~> svn checkout file:///usr/ccrma/group/pid/avr/svn/avrlib ./avrlib

This will create an avrlib directory in your home directory. You can update it anytime from a terminal, by changing into the avrlib directory and typing:

~/avrlib> svn update

OR, you can download the avrlib here:

and decompress it into your home directory with:

~> tar xzf avrlib_ccrma20070124.tar.gz

AVRlib-demos

A set of programs to demonstrate the basic functionalities of the AVRlib and AVRmini are also available. With subversion:

~/somewhere> svn checkout file:///usr/ccrma/group/pid/avr/svn/avrlib-demos ./avrlib-demos

OR, you can download the avrlib-demos:

and decompress them with:

~/somewhere> tar xzf avrlib-demos20070124.tar.gz

The avrlib-demos can reside anywhere, but they assume that the avrlib is in your home directory.


PlanetCCRMA Linux on your own PC

AVR Development Tools

If you have PlanetCCRMA installed on your PC, then you just need to make sure that you have the AVR development packages installed, using yum or apt.

For Fedora Core 4, the AVR compiler tools are under Applications/Development. The AVR downloading/programming tools are under Development/Tools.

AVRlib and avrlib-demos

Download the avrlib and avrlib-demos as described above. Note that you need to get the .tar.gz files, as the svn repository is not available outside of CCRMA.


Mac OS X / Other *nix

These instructions are excerpted from avr-libc" Installing the GNU Tool Chain.

Mac OS X: The Easy Way

1.You need the <tt�>gnumake</tt> program, and you also need a symbolic link to it called make.

There are two options: i) Install Apple's developer tools, which include gnumake and much, much, much more. If you want to develop OSX applications you probably want or already have these anyway. They have a fancy easy-to-use installer.

ii) Alternately, you could just download my copy of gnumake: For PPC: osx-gnumake.tar.gz For Intel:

Then, unstuff it, and install the resulting file like this:

~> tar xzf osc-gnumake.tar.gz
~> sudo mv gnumake /usr/bin
~> sudo ln -s /usr/bin/gnumake /usr/bin/make

2. Download and un-stuff these files: usr-local-avr.tar.gz (31 MB) avrlib_ccrma20070124.tar.gz (998 KB) The contents of avrlib_ccrma20061026.tar.gz is a folder named avrlib - put this folder at the top level of your home directory. The contents of usr-local-avr.tar.gz is a folder named avr - put this folder in your /usr/local directory. (You may first need to make yourself a /usr/local directory and maybe even a /usr directory.) You will probably need to do this as an administrator, like this: sudo mv avr /usr/local Add /usr/local/avr/bin to your Unix path. For example, if you use the tcsh shell, add these three lines to the file .cshrc in your home directory: set path=($path /usr/local/avr/bin) If you use the bash shell, add these six lines to the .bash_profile file in your home directory:

PATH=$PATH:/usr/local/avr/bin export PATH



==

Required Tools:

  • GNU Binutils (currently at version 2.17)

http://sources.redhat.com/binutils/

  • GCC (currently at version 4.1.2)

http://gcc.gnu.org/

  • avr-libc (currently at version 1.4.5)

http://savannah.gnu.org/projects/avr-libc/

  • avrdude (currently at version 5.3.1)

http://savannah.nongnu.org/projects/avrdude/

Windows

Communicating with Pd via OSC over USB

Linux Machines at CCRMA

PlanetCCRMA Linux on your own PC

Mac OS X

Windows

Communicating with Max/MSP via OSC over USB

Mac OS X

Windows

Communicating via OSC over udp