Accessing the AVR's registers

Can I acces the AVR's registers by name as described in the AVR's datasheet?


byte A;


Do I have to include any defintions for this?

Are any peripherals reserved for functions like timer, PWM and such?

Yes, all of those names are defined for you. You can use registers sort of like any other variables.

Timer/Counter 0 is used for the millis(), micros(), delay()... You should not mess with it.

On a UNO/Mini/Nano the UART hardware is used for Serial. PWM (analogWrite()) outputs use timers.

Various libraries use various hardware features. For example, the Servo library uses a timer.

Look in iom328p.h

Didn't compile first time. Reason: everything is case sensitive. Are there any rules for use of case or can I turn case sensitivity off?

PortD=PortD | (1<<LED); //does not compile

That’s because PORTD is spelled “PORTD”, not “PortD”.
Note: There are shortcut operators for statements like “X = X + Y;”:

  X += Y;

The shortcut forms are available for a bunch of binary operators, including “|=”.

Capitalization counts. Always.

can I turn case sensitivity off?


define WDT_vect_num 6

define WDT_vect _VECTOR(6) /* Watchdog Time-out Interrupt */

Mixed up/low case, as well