Some of you may not be aware of this, and it can cost you a LOT of pain with the AVR.
In the larger chips, there are two oscillator modes, one is rail-to-rail, and the other is a low power “vittoz” mode oscillator.
THE VITTOZ MODE OSCILLATOR IS ON BY DEFAULT!
If you don’t select the rail-to-rail oscillator in the fuse bits, then you need to very carefully select your crystal and capacitors, or the level on the oscillator will be too low to reliably clock all of the chip.
Symptoms that this is happening:
1: Serial/I2C/SPI bitrates slightly long. (baud rate generator is skipping cycles)
2: Emulation problems, especially in single stepping (ALU or logic sections not reliably clocked)
3: Non-deterministic execution (!)
You may get ‘lucky’ and not have any noticable problems using the low power oscillator, but this can change on the next date code of AVR chips, the next batch/vendor of crystal, temperature, voltage… I put ‘lucky’ in quotes, because IMHO it’s better that it just curl up and die on the bench, than to have some number work, then fail in production.
Trust me on this, I got bit BAD by this when another engineer on a project specified to turn the low power osc on. We had to recall everything we had shipped, because you can’t set those fuse bits from the program.