Be careful with the terminology: An oscillator is a circuit which generates the clock signal required by the CPU. A crystal is just one part of one type of oscillator circuit.
There are two types of oscillator built into the ATtiny85:
- One type uses an on-chip resistor and capacitor to generate an 8MHz clock. It needs no external components, but it is not very accurate.
- The second type requires an external crystal plus two capacitors. The external components take up space and cost, but the resulting clock is very accurate. You can also choose any frequency, within certain limits.
It's also possible to use the clock signal from an external oscillator, but note that this is not the same as using an external crystal.
Normally the software runs faster or slower in proportion to the clock frequency. However the Arduino software is clever enough to take the CPU clock into account, so delay(1000);
always produces a one-second delay. It also tries to ensure that Serial.begin(9600)
always produces serial data at 9600 bits per second.
What the Arduino software can't do is account for an inaccurate clock. The simplest thing to do is to use an external crystal, as these are manufactured to a high accuracy. Alternatively you can tune the frequency of the internal oscillator, by adjusting the value stored in the OSCCAL register (check the datasheet for more details).
note : There is also a 128kHz clock, but most people will find this too slow.
note : Instead of a crystal a ceramic resonator may be used. It is slightly less accurate, but cheaper and doesn't need the extra capacitors.
note : 0.4 - 20MHz for the ATtiny85, although crystals are only available with certain frequencies in this range. Below 5V the maximum clock frequency is less than 20MHz.