Datasheet
32
ATtiny828 [DATASHEET]
8371A–AVR–08/12
Note: 1. This is the initial value when CKDIV8 fuse has been unprogrammed.
2. This is the initial value when CKDIV8 fuse has been programmed. The device is shipped with the CKDIV8
Fuse programmed.
The initial value of clock prescaler bits is determined by the CKDIV8 fuse (see Table 91 on page 227). When CKDIV8 is
unprogrammed, the system clock prescaler is set to one and, when programmed, to eight. Any value can be written to
the CLKPS bits regardless of the CKDIV8 fuse bit setting.
When CKDIV8 is programmed the initial value of CLKPS bits give a clock division factor of eight at start up. This is useful
when the selected clock source has a higher frequency than allowed under present operating conditions. See “Speed” on
page 249.
To avoid unintentional changes to clock frequency, the following sequence must be followed:
1. Write the required signature to the CCP register. See page 14.
2. Within four instruction cycles, write the desired value to CLKPS bits.
6.6.2 OSCCAL0 – Oscillator Calibration Register
z Bits 7:0 – CAL0[7:0]: Oscillator Calibration Value
The oscillator calibration register is used to trim the internal 8MHz oscillator and to remove process variations from the
oscillator frequency. A pre-programmed calibration value is automatically written to this register during chip reset, giving
the factory calibrated frequency specified in Table 104 on page 249.
The application software can write this register to change the oscillator frequency. The oscillator can be calibrated to
frequencies specified in Table 104 on page 249. Calibration outside that range is not guaranteed.
The lowest oscillator frequency is reached by programming these bits to zero. Increasing the register value increases the
oscillator frequency. A typical frequency response curve is shown in “Calibrated Oscillator Frequency vs. OSCCAL0
Value” on page 295.
Note that this oscillator is used to time EEPROM and Flash write accesses, and write times will be affected accordingly.
Do not calibrate to more than 8.8MHz if EEPROM or Flash is to be written. Otherwise, the EEPROM or Flash write may
fail.
To ensure stable operation of the MCU the calibration value should be changed in small steps. A step change in
frequency of more than 2% from one cycle to the next can lead to unpredictable behavior. Also, the difference between
two consecutive register values should not exceed 0x20. If these limits are exceeded the MCU must be kept in reset
during changes to clock frequency.
Bit 76543210
(0x66) CAL07 CAL06 CAL05 CAL04 CAL03 CAL02 CAL01 CAL00 OSCCAL0
Read/Write R/WR/WR/WR/WR/WR/WR/WR/W
Initial Value Device Specific Calibration Value