211
APPENDIX B
ATmega164 Header File
During C programming, the contents of a specific register may be referred to by name when an
appropriate header file is included within your program. The header file provides the link between
the register name used within a program and the hardware location of the register.
Provided below is the ATmega164 header file from the ICC AVR compiler. This header file
was provided courtesy of ImageCraft.
#ifndef ___iom164to644pv_h #define ___iom164to644pv_h
/* ATmega164..644P io header file for * ImageCraft ICCAVR compiler
*/
/* 2006/10/01 created as iom644pv.h
2008/04/21 added USART bits for SPI mode 2008/05/26 fixed PRR
2009/02/14 added BODS bits to MCUCR
2009/06/26 fixed first line #ifdef */
/* Port D */ #define PIND (*(volatile unsigned char *)0x29)
#define DDRD (*(volatile unsigned char *)0x2A)
#define PORTD (*(volatile unsigned char *)0x2B)
/* Port C */ #define PINC (*(volatile unsigned char *)0x26)
#define DDRC (*(volatile unsigned char *)0x27)
#define PORTC (*(volatile unsigned char *)0x28)
/* Port B */ #define PINB (*(volatile unsigned char *)0x23)
#define DDRB (*(volatile unsigned char *)0x24)
#define PORTB (*(volatile unsigned char *)0x25)
/* Port A */ #define PINA (*(volatile unsigned char *)0x20)
#define DDRA (*(volatile unsigned char *)0x21)
#define PORTA (*(volatile unsigned char *)0x22)
/* Timer/Counter Interrupts */
#define TIFR0 (*(volatile unsigned char *)0x35) #define OCF0B 2
212 B. ATMEGA164 HEADER FILE
#define OCF0A 1 #define TOV0 0
#define TIMSK0 (*(volatile unsigned char *)0x6E) #define OCIE0B 2
#define OCIE0A 1 #define TOIE0 0
#define TIFR1 (*(volatile unsigned char *)0x36) #define ICF1 5
#define OCF1B 2 #define OCF1A 1
#define TOV1 0 #define TIMSK1 (*(volatile unsigned char *)0x6F)
#define ICIE1 5 #define OCIE1B 2
#define OCIE1A 1 #define TOIE1 0
#define TIFR2 (*(volatile unsigned char *)0x37) #define OCF2B 2
#define OCF2A 1 #define TOV2 0
#define TIMSK2 (*(volatile unsigned char *)0x70) #define OCIE2B 2
#define OCIE2A 1 #define TOIE2 0
/* External Interrupts */ #define EIFR (*(volatile unsigned char *)0x3C)
#define INTF2 2 #define INTF1 1
#define INTF0 0 #define EIMSK (*(volatile unsigned char *)0x3D)
#define INT2 2 #define INT1 1
#define INT0 0 #define EICRA (*(volatile unsigned char *)0x69)
#define ISC21 5 #define ISC20 4
#define ISC11 3 #define ISC10 2
#define ISC01 1 #define ISC00 0
/* Pin Change Interrupts */ #define PCIFR (*(volatile unsigned char *)0x3B)
#define PCIF3 3 #define PCIF2 2
#define PCIF1 1 #define PCIF0 0
#define PCICR (*(volatile unsigned char *)0x68) #define PCIE3 3
#define PCIE2 2 #define PCIE1 1
#define PCIE0 0 #define PCMSK0 (*(volatile unsigned char *)0x6B)
#define PCMSK1 (*(volatile unsigned char *)0x6C)
#define PCMSK2 (*(volatile unsigned char *)0x6D)
#define PCMSK3 (*(volatile unsigned char *)0x73)
/* GPIOR */ #define GPIOR0 (*(volatile unsigned char *)0x3E)
#define GPIOR1 (*(volatile unsigned char *)0x4A)
#define GPIOR2 (*(volatile unsigned char *)0x4B)
/* EEPROM */ #define EECR (*(volatile unsigned char *)0x3F)
#define EEPM1 5 #define EEPM0 4
#define EERIE 3 #define EEMPE 2
213
#define EEMWE 2 #define EEPE 1
#define EEWE 1 #define EERE 0
#define EEDR (*(volatile unsigned char *)0x40)
#define EEAR (*(volatile unsigned int *)0x41)
#define EEARL (*(volatile unsigned char *)0x41)
#define EEARH (*(volatile unsigned char *)0x42)
/* GTCCR */ #define GTCCR (*(volatile unsigned char *)0x43)
#define TSM 7 #define PSRASY 1
#define PSR2 1 #define PSRSYNC 0
#define PSR10 0
/* Timer/Counter 0 */ #define OCR0B (*(volatile unsigned char *)0x48)
#define OCR0A (*(volatile unsigned char *)0x47)
#define TCNT0 (*(volatile unsigned char *)0x46)
#define TCCR0B (*(volatile unsigned char *)0x45) #define FOC0A 7
#define FOC0B 6 #define WGM02 3
#define CS02 2 #define CS01 1
#define CS00 0 #define TCCR0A (*(volatile unsigned char *)0x44)
#define COM0A1 7 #define COM0A0 6
#define COM0B1 5 #define COM0B0 4
#define WGM01 1 #define WGM00 0
/* SPI */ #define SPCR (*(volatile unsigned char *)0x4C)
#define SPIE 7 #define SPE 6
#define DORD 5 #define MSTR 4
#define CPOL 3 #define CPHA 2
#define SPR1 1 #define SPR0 0
#define SPSR (*(volatile unsigned char *)0x4D) #define SPIF 7
#define WCOL 6 #define SPI2X 0
#define SPDR (*(volatile unsigned char *)0x4E)
/* Analog Comparator Control and Status Register */
#define ACSR (*(volatile unsigned char *)0x50) #define ACD 7
#define ACBG 6 #define ACO 5
#define ACI 4 #define ACIE 3
#define ACIC 2 #define ACIS1 1
#define ACIS0 0

Get Atmel AVR Microcontroller Primer, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.