Data Sheet

99
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
14.6.2.6 Selecting a Clock Source for the Generic Clock Generator
Each generic clock generator can individually select a clock source by writing to the Source Select bit group in
GENCTRL (GENCTRL.SRC). Changing from one clock source, A, to another clock source, B, can be done on the fly. If
clock source B is not ready, the generic clock generator will continue running with clock source A. As soon as clock
source B is ready, however, the generic clock generator will switch to it. During the switching, the generic clock generator
holds clock requests to clock sources A and B and then releases the clock source A request when the switch is done.
The available clock sources are device dependent (usually the crystal oscillators, RC oscillators, PLL and DFLL clocks).
GCLKGEN[1] can be used as a common source for all the generic clock generators except generic clock generator 1.
14.6.2.7 Changing Clock Frequency
The selected generic clock generator source, GENCLKSRC can optionally be divided by writing a division factor
in the Division Factor bit group in the Generic Clock Generator Division register (GENDIV.DIV). Depending on the value
of the Divide Selection bit in GENCTRL (GENCTRL.DIVSEL), it can be interpreted in two ways by the integer divider.
Note that the number of DIV bits for each generic clock generator is device dependent.
Refer to Table 14-11 for details.
14.6.2.8 Duty Cycle
When dividing a clock with an odd division factor, the duty-cycle will not be 50/50. Writing a one to the Improve Duty
Cycle bit in GENCTRL (GENCTRL.IDC) will result in a 50/50 duty cycle.
14.6.2.9 Generic Clock Output on I/O Pins
Each Generic Clock Generator's output can be directed to a GCLK_IO pin. If the Output Enable bit in GENCTRL
(GENCTRL.OE) is one and the generic clock generator is enabled (GENCTRL.GENEN is one), the generic clock
generator requests its clock source and the GCLKGEN clock is output to a GCLK_IO pin. If GENCTRL.OE is zero,
GCLK_IO is set according to the Output Off Value bit. If the Output Off Value bit in GENCTRL (GENCTRL.OOV) is zero,
the output clock will be low when generic clock generator is turned off. If GENCTRL.OOV is one, the output clock will be
high when generic clock generator is turned off.
In standby mode, if the clock is output (GENCTRL.OE is one), the clock on the GCLK_IO pin is frozen to the OOV value
if the Run In Standby bit in GENCTRL (GENCTRL.RUNSTDBY) is zero. If GENCTRL.RUNSTDBY is one, the GCLKGEN
clock is kept running and output to GCLK_IO.
14.6.3 Generic Clock
Figure 14-4. Generic Clock Multiplexer
14.6.3.1 Enabling a Generic Clock
Before a generic clock is enabled, one of the generic clock generators must be selected as the source for the generic
clock by writing to CLKCTRL.GEN. The clock source selection is individually set for each generic clock.
C
loc
k
G
at
e
GCLK_PERIPHERAL
C
LKCTRL.GEN
C
LK
C
TRL.
C
LKEN
GCLKGEN
[
0
]
GC
LK
G
EN[1]
GC
LK
G
EN[2]
GCLKGEN
[
n
]