ICCAVR – C Cross Compiler for the Atmel AVR
- 10 -
http://www.cs.virginia.edu/~lcc-win32. The tool also includes Jack Tidwell's AvrCalc program. The
Application Builder is written by Andy Clark. Check out Andy's ACIDE program and his AVR+GameBoy
(tm) project: http://pages.zoom.co.uk/andyc/ . The ISP code is written by Claudio Lanconelli. Check out
Claudio's Pony Programmer at http://www.lancOS.com
The PROFESSIONAL version includes the GNU RCS utilities and the grep program. The GNU copyleft
license specifies that you may redistribute the GNU programs. This does not apply to any other software
in this package that is not GNU based. ImageCraft has not modified the GNU programs. GNU program
source and binary code can be found on http://www.gnu.org
All code used with permission. Please report ALL bugs to us directly.
TUTORIALS
Getting Started
Once you invoke the IDE, choose Project->Open from the menu system. Navigate to the
\icc\examples.avr directory and select the project "led." The project manager displays the filename led.c
indicating there is one file in this project. Select the project compilation option by choosing Project-
>Options. Under the "Target" tab, select the target processor.
Now select Project->Make. The IDE invokes the compiler to compile the project files and display any
messages in the Status Window.
Assuming there is no error, an output file called led.hex is produced in the same directory as your source
file; in this case, \icc\examples.avr. This is a file in Intel HEX format. Most AVR programmers and
simulators understand this format, and you can load this program into your target. That's all there is to
build a program!
If you want to test your program on a tool that accepts COFF debug information, for example the AVR
Studio, then you need to select COFF as the output file format under Project->Options. Notice that the
often used functions are also available in the button bar and as context sensitive right mouse pop-up
menus. For example, you can choose the compiler options by right clicking on the Project Window.
Double clicking a file name in the Project Window opens it in the Editor. Go ahead and open led.c this
way. For experimentation, try to introduce errors, for example, delete a semicolon ";" from a line. Now
select Project->Build. The IDE will ask you if you want to save the changes first. Select yes and the
compilation will commence. This time there should be an error displayed in the Status Window. Clicking
on the error line, or clicking on the error symbol on the left on the error line will move the cursor to the
offending line in the Editor.
Starting a New Project
Select Project->New and browse to a directory where you want to put your project files. The name of the
output is based on the name of your project file so for example, if you create a project name foo.prj, the
output file name is foo.hex, or foo.cof etc.
Once you create your project, you can start writing source code (in C or assembly) and add the source
files to the project file list. See Using the Project Manager. Building the project is as easy as clicking on
the "Build" toolbar icon. The output COFF file is fully compatible with Atmel's AVR Studio, which you can
use to debug your code. See COFF and Working With AVR Studio.
To further ease the development process, you can use the Application Builder to generate peripheral
initialization code.
Anatomy of a C Program
A C program must define a function called main. The compiler links your program with the startup code
and the library functions into an "executable" file, so called because you can execute it on your target.
The purpose of the startup code is described in detail in Startup File. In summary, a C program needs
the target environment to be set up in certain ways and the startup code initializes the target to satisfy