Atmel ARM-Based Evaluation Kit for SAM4S16C, 32-Bit ARM® Cortex® Microcontroller ATSAM4S-WPIR-RD ATSAM4S-WPIR-RD Data Sheet

Product codes
ATSAM4S-WPIR-RD
Page of 1231
503
SAM4S Series [DATASHEET]
Atmel-11100G-ATARM-SAM4S-Datasheet_27-May-14
Controller Status Register (PMC_SR) is cleared and the counter starts counting down on the slow clock divided by 
8 from the MOSCXTST value. Since the MOSCXTST value is coded with 8 bits, the maximum start-up time is 
about 62 ms.
When the counter reaches 0, the MOSCXTS bit is set, indicating that the main clock is valid. Setting the 
MOSCXTS bit in PMC_IMR can trigger an interrupt to the processor.
28.5.4 Main Clock Oscillator Selection
The user can select either the 4/8/12 MHz fast RC oscillator or the 3 to 20 MHz crystal or ceramic resonator-based 
oscillator to be the source of main clock.
The advantage of the 4/8/12 MHz fast RC oscillator is that it provides fast start-up time, this is why it is selected by 
default (to start up the system) and when entering wait mode.
The advantage of the 3 to 20 MHz crystal or ceramic resonator-based oscillator is that it is very accurate.
The selection is made by writing the MOSCSEL bit in the Main Oscillator Register (CKGR_MOR). The switch of 
the main clock source is glitch free, so there is no need to run out of SLCK, PLLACK in order to change the 
selection. The MOSCSELS bit of the Power Management Controller Status Register (PMC_SR) indicates when 
the switch sequence is done.
Setting the MOSCSELS bit in PMC_IMR can trigger an interrupt to the processor.
Enabling the fast RC oscillator (MOSCRCEN = 1) and changing the fast RC frequency (MOSCCRF) at the same 
time is not allowed.
The fast RC must be enabled first and its frequency changed in a second step.
28.5.5 Switching Main Clock between the Main RC Oscillator and Fast Crystal Oscillator
Both sources must be enabled during the switchover operation. Only after completion can the unused oscillator be 
disabled. If switching to fast crystal oscillator, the clock presence must first be checked according to what is 
described in 
 because the source may 
not be reliable (crystal failure or bypass on a non-existent clock).
28.5.6 Software Sequence to Detect the Presence of Fast Crystal
The frequency meter carried on the CKGR_MCFR register is operating on the selected main clock and not on the 
fast crystal clock nor on the fast RC oscillator clock.
Therefore, to check for the presence of the fast crystal clock, it is necessary to have the main clock (MAINCK) 
driven by the fast crystal clock (MOSCSEL=1).
The following software sequence order must be followed:
̶
MCK must select the slow clock (CSS=0 in the PMC_MCKR register).
̶
Wait for the MCKRDY flag in the PMC_SR register to be 1.
̶
The fast crystal must be enabled by programming 1 in the MOSCXTEN field in the CKGR_MOR 
register with the MOSCXTST field being programmed to the appropriate value (see the Electrical 
Characteristics chapter).
̶
Wait for the MOSCXTS flag to be 1 in the PMC_SR register to get the end of a start-up period of the 
fast crystal oscillator.
̶
Then, MOSCSEL must be programmed to 1 in the CKGR_MOR register to select fast main crystal 
oscillator for the main clock.
̶
MOSCSEL must be read until its value equals 1.
̶
Then the MOSCSELS status flag must be checked in the PMC_SR register.
At this point, 2 cases may occur (either MOSCSELS = 0 or MOSCSELS = 1).