Register Definitions for ATmega328P

Is there a header file containing structs of register definitions I can reference for the microcontroller on the arduino uno? I want to be able to quickly look up what they call timer 1 (ie TMR1ON or T1ON or T1EN or TMR1.Enable, etc) for whatever compiler the Arduino processing IDE uses.

Does anyone have any other good tips on quickly learning the new registers for the ATmega328P? They don't seem to be described in some central area of the datasheet with a listing of descriptions for what setting each bit does like some PIC datasheets do.

Thanks.

The datasheet is very good for all the register descriptions. The header files that contain the information do exist; however, they simply say things like

#define DDRC _SFR_IO8(0x07)
#define _SFR_IO8(io_addr) _MMIO_BYTE((io_addr) + __SFR_OFFSET)
#define __SFR_OFFSET 0x20
#define _MMIO_BYTE(mem_addr) (*(volatile uint8_t *)(mem_addr))

On linux, they're under /usr/avr/include; on windows they're in [arduinodirectory]/hardware/tools/avr/avr/include

Thank you!

They are normally included by “#include <avr/io.h>” which includes a proper sub-file depending on the “-mmcu=xxxx” switch to the compiler. I think it’s fussy enough to complain if you don’t do it that way.

Strictly non-structure based, matching the datasheets. So you get

#define TCCR1B  _SFR_MEM8 (0x81)
/* TCCR1B */
#define ICNC1   7
#define ICES1   6
#define WGM13   4
#define WGM12   3
#define CS12    2
#define CS11    1
#define CS10    0

/*
 * and to enable the timer, you do stuff like:
 */

TCCR1B = (_BV(CS10));   // enable timer by selecting a clock source + other bits that happen to be zero.

It’s a particular pet peeve of mine that the same bits for a different timer (or uart) of THE SAME TYPE will have different bit names for the same values (a second 16bit timer might say TCCR3B = _BV(CS30):wink: Grr. But it matches the Atmel documentation.

The data sheets have a reasonably nice “register summary” section that lists all of the registers and most of the bit names, with a hyperlink to the page where the bits are described in more detail. (Chapter 30 in my version of the 328p datasheet.)