Atmel Xplained Pro Evaluation Kit ATSAM4E-XPRO ATSAM4E-XPRO Data Sheet

Product codes
ATSAM4E-XPRO
Page of 1506
581
SAM4E [DATASHEET]
Atmel-11157D-ATARM-SAM4E16-SAM4E8-Datasheet_12-Jun-14
29.5.6   Software Sequence to Detect the Presence of Fast Crystal
The frequency meter carried on  CKGR_MCFR 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 Master Clock register (PMC_MCKR) register).
̶
Wait for the MCKRDY flag in  PMC_SR 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 section).
̶
Wait for the MOSCXTS flag to be 1 in PMC_SR to get the end of a start-up period of the fast crystal 
oscillator.
̶
Then, MOSCSEL must be programmed to 1 in CKGR_MOR 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 PMC_SR.
At this point, 2 cases may occur (either MOSCSELS = 0 or MOSCSELS = 1). 
̶
If MOSCSELS = 1, there is a valid crystal connected and its frequency can be determined by initiating 
a frequency measure by programming RCMEAS in CKGR_MCFR.
̶
If MOSCSELS = 0, there is no fast crystal clock (either no crystal connected or a crystal clock out of 
specification).
A frequency measure can reinforce this status by initiating a frequency measure by programming 
RCMEAS in CKGR_MCFR.
̶
If MOSCSELS=0, the selection of the main clock must be programmed back to the main RC oscillator 
by writing MOSCSEL to 0 prior to disabling the fast crystal oscillator.
̶
If MOSCSELS=0, the crystal oscillator can be disabled (MOSCXTEN=0 in CKGR_MOR).