Atmel Xplained Pro Evaluation Kit for the ATSAMD21J18A Microcontroller ATSAMD21-XPRO ATSAMD21-XPRO Data Sheet

Product codes
ATSAMD21-XPRO
Page of 1018
221
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181C–SAM-D21_Datasheet–07/2014
18.6 Functional Description
18.6.1 Principle of Operation
The RTC keeps track of time in the system and enables periodic events, as well as interrupts and events at a specified 
time. The RTC consists of a 10-bit prescaler that feeds a 32-bit counter. The actual format of the 32-bit counter depends 
on the RTC operating mode.
18.6.2 Basic Operation
18.6.2.1  Initialization
The following bits are enable-protected, meaning that they can only be written when the RTC is disabled (CTRL.ENABLE 
is zero):   
z
Operating Mode bits in the Control register (CTRL.MODE) 
z
Prescaler bits in the Control register (CTRL.PRESCALER) 
z
Clear on Match bit in the Control register (CTRL.MATCHCLR) 
z
Clock Representation bit in the Control register (CTRL.CLKREP) 
The following register is enable-protected:
z
Any writes to these bits or registers when the RTC is enabled or being enabled (CTRL.ENABLE is one) will be discarded. 
Writes to these bits or registers while the RTC is being disabled will be completed after the disabling is complete. 
Enable-protection is denoted by the Enable-Protection property in the register description.
Before the RTC is enabled, it must be configured, as outlined by the following steps: 
z
RTC operation mode must be selected by writing the Operating Mode bit group in the Control register 
(CTRL.MODE)
z
Clock representation must be selected by writing the Clock Representation bit in the Control register 
(CTRL.CLKREP)
z
Prescaler value must be selected by writing the Prescaler bit group in the Control register (CTRL.PRESCALER)
The RTC prescaler divides down the source clock for the RTC counter. The frequency of the RTC clock 
(CLK_RTC_CNT) is given by the following formula:
The frequency of the generic clock, GCLK_RTC, is given by f
GCLK_RTC
, and f
CLK_RTC_CNT
 is the frequency of the internal 
prescaled RTC clock, CLK_RTC_CNT. 
Note that in the Clock/Calendar mode, the prescaler must be configured to provide a 1Hz clock to the counter for correct 
operation.
18.6.2.2  Enabling, Disabling and Resetting
The RTC
 
is enabled by writing a one to the Enable bit in the Control
 
register (CTRL.ENABLE). The RTC is disabled by 
writing a zero to CTRL.ENABLE.
The RTC should be disabled before resetting it.
The RTC
 
is reset by writing a one to the Software Reset bit in the Control register (CTRL.SWRST). All registers in the 
RTC, except DBGCTRL, will be reset to their initial state, and the RTC will be disabled. 
Refer to the 
f
CLK_RTC_CNT
f
GCLK_RTC
2
PRESCALER
-----------------------------
=