ATmega128
Timer/Counter Oscillator
For AVR microcontrollers with Timer/Counter Oscillator pins (TOSC1 and TOSC2), the
crystal is connected directly between the pins. No external capacitors are needed. The
Oscillator is optimized for use with a 32.768 kHz watch crystal. Applying an external
clock source to TOSC1 is not recommended.
Note: The Timer/Counter Oscillator uses the same type of crystal oscillator as Low-Frequency
Oscillator and the internal capacitors have the same nominal value of 36 pF.
XTAL Divide Control Register
– XDIV
The XTAL Divide Control Register is used to divide the Source clock frequency by a
number in the range 2 - 129. This feature can be used to decrease power consumption
when the requirement for processing power is low.
Bit
Read/Write
Initial Value
7
XDIVEN
R/W
0
6
XDIV6
R/W
0
5
XDIV5
R/W
0
4
XDIV4
R/W
0
3
XDIV3
R/W
0
2
XDIV2
R/W
0
1
XDIV1
R/W
0
0
XDIV0
R/W
0
XDIV
• Bit 7 – XDIVEN: XTAL Divide Enable
When the XDIVEN bit is written one, the clock frequency of the CPU and all peripherals
(clkI/O, clkADC, clkCPU, clkFLASH) is divided by the factor defined by the setting of XDIV6 -
XDIV0. This bit can be written run-time to vary the clock frequency as suitable to the
application.
• Bits 6..0 – XDIV6..XDIV0: XTAL Divide Select Bits 6 - 0
These bits define the division factor that applies when the XDIVEN bit is set (one). If the
value of these bits is denoted d, the following formula defines the resulting CPU and
peripherals clock frequency fCLK:
fCLK
=
S----o----u---r--c---e-----c---l--o---c---k-
129 – d
The value of these bits can only be changed when XDIVEN is zero. When XDIVEN is
written to one, the value written simultaneously into XDIV6..XDIV0 is taken as the divi-
sion factor. When XDIVEN is written to zero, the value written simultaneously into
XDIV6..XDIV0 is rejected. As the divider divides the master clock input to the MCU, the
speed of all peripherals is reduced when a division factor is used.
Note:
When the system clock is divided, Timer/Counter0 can be used with Asynchronous clock
only. The frequency of the asynchronous clock must be lower than 1/4th of the frequency
of the scaled down Source clock. Otherwise, interrupts may be lost, and accessing the
Timer/Counter0 registers may fail.
43
2467O–AVR–10/06