Looking for some reading material

Hi
I’m looking for some reading material on the Arduino information working with the internal registers.
I read someplace not to mess with Timer 0 because it used in all timed based items like delay().
Are there any special rules with Timer 1 and Timer 2? What about using other AVR interrupts and sleep modes? Is there any restrictions using PORTx or DDRx registers directly? Why use _BV() macro?
Do you have to restore anything when done?

I met someone here that designed a library that used output compare with Timer1 and Timer2.
Also used external interrupts 0 and 1 too. I didn’t realize you could access these timers and registers
directly. Maybe we could make a pdf or something. I’m just looking to expand my knowledge of the language and Arduino.

Thank you for reading the thread.
Don

You can mess with whatever you want, it’s your chip. :slight_smile:

However they have packed quite a bit into a small chip, so various things tend to be inter-dependent. For example, the Tone library uses a timer. The analogWrite (PWM write) uses timers. You can use sleep if you want. You can use most interrupts if you want. One is already used for Timer0 overflow for the millis() function.

Some additional reading:

http://www.gammon.com.au/interrupts
Gammon Forum : Electronics : Microprocessors : Timers and counters (timers)
Gammon Forum : Electronics : Microprocessors : Power saving techniques for microprocessors

The _BV macro is a simple way of accessing a bit. eg. bit 4 (the 5th bit) can be ored in like this:

PORTD |= 1 << 4;

Or you can use _BV:

PORTD |= _BV (4);

I suggest you download the Atmega328 datasheet, if you haven’t already.

Nick Thanks for your reply. I was on your site this afternoon. I like your shift register 74hc597 project well made. Don

Nick
Which logic analyzer do you have? Looks like a pc based one nice! I have a Aruim ML4400.
Don

This one:

http://www.saleae.com/logic/

I actually use it on my Mac. It runs on Mac, Windows, Linux.

Nick looks really nice I could live with 8 channels these days. Mine is old and I have to use my cell to make a screen shot. It has a pod for 68HC11 dissembler which I used before the Atmel Avr became so popular I got it cheap and have had it for 18 years now.
Don