
AT32F413
Series Reference Manual
2022.06.27
Page 260
Rev 2.00
17.4.2 Reading RTC registers
Based on synchronization logic, there is a probability that the correct values have yet been uploaded
from the battery powered domain to the APB1 interface while reading the RTC registers at one of the
following events:
A system reset or power reset;
The microcontroller has woken up from Standby or Deepsleep modes.
In this case, the software must wait until UPDF=1 before reading RTC registers, otherwise, an error
value is returned.
17.4.3 RTC interrupts
RTC supports the following interrupt requests:
Second interrupt: If Second interrupt is enabled (TSIEN=1), a second interrupt is generated at
each LN_CLK period.
Alarm interrupt: If Alarm interrupt is enabled (TAIEN=1), an alarm interrupt is generated when the
value in the TA register is equal to the CTN value.
Overflow interrupt: If Overflow interrupt is enabled (OVFIEN=1), an overflow interrupt is
generated when the counter reaches the value 0xFFFFFFFF.
The RTC global interrupt vector (RTC_IRQn) and alarm interrupt vector (RTCAlarm_IRQn) are both
supported. To wake up from DEEPSLEEP mode using the RTC alarm interrupt, the RTC alarm interrupt
must be enabled to use the RTCAlarm_IRQn vector, and the EXINT 17 is configured as interrupt mode
at the same time; To wake from DEEPSLEEP mode using the RTC alarm event, the EXINT 17 must be
configured as event mode, but without the need of enabling the RTC alarm interrupt. When the RTC
alarm event is used to wake up from Standby mode, it is not necessary to enable alarm interrupt and
EXINT 17.
RTC flag bits are described as follows:
RTC Second flag (TSF): It indicates the update of RTC counter. The Second flag is set one
RTC_CLK period before the update of the RTC counter
RTC Alarm flag (TAF): The flag is set one RTC_CLK period before the counter value reaches the
RTC alarm value in the alarm register increased by one (TA+1)
RTC Overflow flag (OVFF): The flag is set one RTC_CLK period before the RTC counter value
reaches the value 0x00000000
When the RTC interrupts are generated, clearing the corresponding flag bits means that the interrupt
requests have been received. The flag bits can only be set by hardware, and cleared by software. After
reset, all interrupts will be disabled. The flag bits will no longer be updated when the APB1 clock stops
running.
Figure 17-2
RTC second and alarm waveform example with DIV=0004 and TA=00004
RTC_CLK
RTC_Second
RTC_CNT
RTC_ALARM
ALAF
Can be cleared by software
0
1
2
3
4
5