25.5.9. Analog Connections
A 32.768kHz crystal can be connected to the XIN32 and XOUT32 pins, along with any required load
capacitors. See Electrical Characteristics for details on recommended crystal characteristics and load
capacitors.
Related Links
on page 1147
25.6. Functional Description
25.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.
The RTC can function in one of these modes:
•
Mode 0 - COUNT32: RTC serves as 32-bit counter
•
Mode 1 - COUNT16: RTC serves as 16-bit counter
•
Mode 2 - CLOCK: RTC serves as clock/calendar with alarm functionality
25.6.2. Basic Operation
25.6.2.1. Initialization
The following bits are enable-protected, meaning that they can only be written when the RTC is disabled
(CTRLA.ENABLE=0):
•
Operating Mode bits in the Control A register (CTRLA.MODE)
•
Prescaler bits in the Control A register (CTRLA.PRESCALER)
•
Clear on Match bit in the Control A register (CTRLA.MATCHCLR)
•
Clock Representation bit in the Control A register (CTRLA.CLKREP)
The following registers are enable-protected:
The following register is enable-protected
•
Control B register (CTRLB)
•
Event Control register (EVCTRL)
•
Tamper Control register (TAMPCTRL)
Enable-protected bits and registers can be changed only when the RTC is disabled (CTRLA.ENABLE=0).
If the RTC is enabled (CTRLA.ENABLE=1), these operations are necessary: first write
CTRLA.ENABLE=0 and check whether the write synchronization has finished, then change the desired
bit field value. Enable-protected bits in can be written at the same time as CTRLA.ENABLE is written to
'1', but not at the same time as CTRLA.ENABLE is written to '0'.
Enable-protection is denoted by the "Enable-Protected" property in the register description.
The RTC prescaler divides the source clock for the RTC counter.
Note:
In Clock/Calendar mode, the prescaler must be configured to provide a 1Hz clock to the counter
for correct operation.
The frequency of the RTC clock (CLK_RTC_CNT) is given by the following formula:
Atmel SAM L22G / L22J / L22N [DATASHEET]
Atmel-42402E-SAM L22G / L22J / L22N_Datasheet_Complete-07/2016
335