3 I/O Header Files

I/O header files contain identifiers for all the register names and bit names for a particular processor. They must be included when registers are being used in the code.

AVR GCC has individual I/O header files for each processor. However, the actual processor type is specified as a command line flag to the compiler. (Using the -mmcu= processor flag.) This is usually done in the Makefile. This allows you to specify only a single header file for any processor type:

#include <avr/io.h>

IAR also allows you to specify only a single header file for any processor type:

#include <ioavr.h>

The GCC and IAR compilers know the processor type and through the single header file above, it can pull in and include the correct individual I/O header file. This has the advantage that you only have to specify one generic header file, and you can easily port your application to another processor type without having to change every file to include the new I/O header file.

Note: IAR does not always use the same register names or bit names that are used in the AVR datasheet. There may be some discrepancies between the register names found in the AVR GCC I/O header files and the IAR I/O header files.