Atmel Evaluation Kit AT91SAM9G25-EK AT91SAM9G25-EK Data Sheet

Product codes
AT91SAM9G25-EK
Page of 1165
181
SAM9G25 [DATASHEET]
11032D–ATARM–10-Mar-2014
21.6.2 Switch from Internal 12 MHz RC Oscillator to the 12 MHz Crystal
For USB operations an external 12 MHz crystal is required for better accuracy.
The programmer controls the main clock switching by software and so must take precautions during the switching phase. 
To switch from internal 12 MHz RC oscillator to the 12 MHz crystal, the programmer must execute the following 
sequence:
Enable the 12 MHz oscillator by setting the bit MOSCXTEN to 1.
Wait that the 12 MHz oscillator status bit MOSCXTS is 1.
Switch from internal 12 MHz RC oscillator to the 12 MHz oscillator by setting the bit MOSCSEL to 1.
If not the bit MOSCSEL is set to 0 by the PMC.
Disable the 12 MHz RC oscillator by setting the bit MOSCRCEN to 0.
21.6.3 Bypass the 12 MHz Oscillator
Following step must be added to bypass the 12 MHz Oscillator.
An external clock must be connected on XIN.
Enable the bypass path MOSCXTBY bit set to 1.
Disable the 12 MHz oscillator by setting the bit MOSCXTEN to 0.
21.6.4 Switch from the 12 MHz Crystal to Internal 12 MHz RC Oscillator
The same procedure must be followed to switch from a 12 MHz crystal to the internal 12 MHz RC oscillator.
Enable the internal 12 MHz RC oscillator for low power by setting the bit MOSCRCEN to 1
Wait internal 12 MHz RC Startup Time for clock stabilization (software loop).
Switch from 12 MHz oscillator to internal 12 MHz RC oscillator by setting the bit MOSCSEL to 0.
Disable the 12 MHz oscillator by setting the bit MOSCXTEN to 0.
21.6.5 12 MHz Fast RC Oscillator
After reset, the 12 MHz Fast RC Oscillator is enabled and it is selected as the source of MCK. MCK is the default clock 
selected to start up the system. 
Please refer to the “DC Characteristics” section of the product datasheet.
The software can disable or enable the 12 MHz Fast RC Oscillator with the MOSCRCEN bit in the Clock Generator Main 
Oscillator Register (CKGR_MOR).
When disabling the Main Clock by clearing the MOSCRCEN bit in CKGR_MOR, the MOSCRCS bit in the Power 
Management Controller Status Register (PMC_SR) is automatically cleared, indicating the Main Clock is off.
Setting the MOSCRCS bit in the Power Management Controller Interrupt Enable Register (PMC_IER) can trigger an 
interrupt to the processor.
21.6.6 12 to 16 MHz Crystal Oscillator
After reset, the 12 to 16 MHz Crystal Oscillator is disabled and it is not selected as the source of MAINCK.
The user can select the 12 to 16 MHz crystal oscillator to be the source of MAINCK, as it provides a more accurate 
frequency. The software enables or disables the main oscillator so as to reduce power consumption by clearing the 
MOSCXTEN bit in the Main Oscillator Register (CKGR_MOR). 
When disabling the main oscillator by clearing the MOSCXTEN bit in CKGR_MOR, the MOSCXTS bit in PMC_SR is 
automatically cleared, indicating the Main Clock is off.
When enabling the main oscillator, the user must initiate the main oscillator counter with a value corresponding to the 
startup time of the oscillator. This startup time depends on the crystal frequency connected to the oscillator.
When the MOSCXTEN bit and the MOSCXTCNT are written in CKGR_MOR to enable the main oscillator, the 
MOSCXTS bit in the Power Management Controller Status Register (PMC_SR) is cleared and the counter starts