279
SAM4CP [DATASHEET]
43051E–ATPL–08/14
16.4
Functional Description
The programmable 16-bit prescaler value can be configured through the RTPRES field in the
“Real-time Timer Mode
Register”
(RTT_MR).
Configuring the RTPRES field value to 0x8000 (default value) corresponds to feeding the real-time counter with a 1Hz
signal (if the slow clock is 32.768 kHz). The 32-bit counter can count up to 2
32
seconds, corresponding to more than 136
years, then roll over to 0. Bit RTTINC in the
“Real-time Timer Status Register”
(RTT_SR) is set each time there is a
prescaler roll-over (see
Figure 16-2
).
The real-time 32-bit counter can also be supplied by the 1 Hz RTC clock. This mode is interesting when the RTC 1Hz is
calibrated (CORRECTION field
≠
0 in RTC_MR) in order to guaranty the synchronism between RTC and RTT counters.
Setting the RTC1HZ bit in the RTT_MR drives the 32-bit RTT counter from the 1Hz RTC clock. In this mode, the
RTPRES field has no effect on 32-bit counter.
The prescaler roll-over generates an increment of the real-time timer counter if RTC1HZ = 0. Otherwise, if RTC1HZ = 1,
the real-time timer counter is incremented every second. The RTTINC bit is set independently from the 32-bit counter
increment.
The Real-time Timer can also be used as a free-running timer with a lower time-base. The best accuracy is achieved by
writing RTPRES to 3 in RTT_MR.
Programming RTPRES to 1 or 2 is forbidden. If the RTT is configured to trigger an interrupt, the interrupt occurs during 2
Slow Clock cycles after reading RTT_SR. To prevent several executions of the interrupt handler, the interrupt must be
disabled in the interrupt handler and re-enabled when the RTT_SR is cleared.
The CRTV field can be read at any time in the
“Real-time Timer Value Register”
(RTT_VR). As this value can be updated
asynchronously with the Master Clock, the CRTV field must be read twice at the same value to improve accuracy of the
returned value.
The current value of the counter is compared with the value written in the
“Real-time Timer Alarm Register”
(RTT_AR). If
the counter value matches the alarm, the ALMS bit in the RTT_SR is set. The RTT_AR is set to its maximum value
(0xFFFF_FFFF) after a reset.
The ALMS flag is always a source of the RTT alarm signal that may be used to exit the system from low power modes
(see
Figure 16-1
)
The alarm interrupt must be disabled (ALMIEN must be cleared in RTT_MR) when writing a new ALMV value in the
RTT_AR.
The RTTINC bit can be used to start a periodic interrupt, the period being one second when the RTPRES field
value=0x8000 and slow clock = 32.768 kHz.
The RTTINCIEN bit must be cleared prior to writing a new RTPRES value in the RTT_MR.
Reading the RTT_SR automatically clears the RTTINC and ALMS bits.
Writing the RTTRST bit in the RTT_MR immediately reloads and restarts the clock divider with the new programmed
value. This also resets the 32-bit counter.
When not used, the Real-time Timer can be disabled in order to suppress dynamic power consumption in this module.
This can be achieved by setting the RTTDIS bit in the RTT_MR.