Projects for geeks


11 Aug 2009

All examples are written for ATmega16 or ATmega32 with 8MHz clock. Software can be easily converted to work with any other AVR chip.

The source code is written in C for free AVR GCC compiler. AVR Studio 4 project files available as well.

All schematics shows working devices. If internal RC oscillator is used appropriate fuse bits must be set. All devices can be assembled on breadboard. Examples were tested using Aquaticus control unit and Aquaticus JTAG (but JTAG is not required you can use an ordinary ISP programmer if you like).


To compile sample code you must:

  1. Download and install free AVR GCC compiler.
  2. Install Atmel AVR Studio 4

The last step is optional if you know how to compile programs using only command line tools.

Sample usage

Download attached zip file and unpack it. Then run AVR Studio and open file with aps extension.

First be sure you set microcontroller type and system clock frequency in Project/Configuration Options (see Problems section for more info).
Select menu Build/Build (or press F7) to compile the example. If everything was ok, you should see file with hex extension in default directory. This file can be used to flash microcontroller using your preferred tool.

System clock

It was assumed that AVR microcontroller system clock is 8MHz. Clock source does not matter, it may be internal RC oscillator or any external clock source.

Brand new ATmega16, ATmega32 and other AVR chips are shipped with 1MHz internal RC oscillator as clock source. To use those chips to run example code you must change it to 8MHz. To do that you must set appropriate fuse bits. Look at the picture below to see a typical settings for ATmega32 8MHz RC oscillator (most important CKSEL bits).


Here is the list of typical problems.

1. Wrong micro controller type. Examples are build for ATmega16 or ATmega32 chips.
2. Wrong system clock. By default all the examples uses 8MHz.

To solve above problems, you must go to Project/Configuration Options and set values marked red in the following image.