![ARTERY AT32F435 Series Скачать руководство пользователя страница 341](http://html1.mh-extra.com/html/artery/at32f435-series/at32f435-series_reference-manual_2977592341.webp)
AT32F435/437
Series Reference Manual
2022.11.11
Page 341
Rev 2.03
time synchronization. In this mode, the UPDF flag is cleared by hardware. To ensure the data is correct
when reading clock and calendar, the software must read the clock and calendar registers twice, and
compare the results of two read operations. If the result is not aligned, read again until that the results
of two read accesses are consistent. Besides, it is also possible to compare the least significant bits of
the two read operations to determine their consistency.
Note: In Standby and Deepsleep modes, the current calendar values are not copied into the shadow
registers. When waking up from these two modes, UPDF=0 must be asserted, and then wait until
UPDF=1, to ensure that the latest calendar value can be read. In synchronous read (DREN=0) mode,
the frequency of the PCLK1 must be at least seven times the ERTC_CLK frequency. In asynchronous
read (DREN=1), an additional APB cycle is required to complete the read operations of the calendar
register.
Alarm clock initialization
The ERTC contains two programmable alarm clocks: alarm clock A and alarm clock B, and their
respective interrupts.
The
alarm
clock
value
is
programmed
with
the
ERTC_ALASBS/ERTC_ALA
(ERTC_ALBSBS/ERTC_ALB). When the programmed alarm value matches the calendar value, an
alarm event is generated if an alarm clock is enabled. The MASKx bit can be used to selectively mask
calendar fields. The calendar fields, which are masked, are not allocated with an alarm clock.
To configure the alarm clocks, the following steps should be respected:
1.
Disable alarm clock A or alarm clock B (by setting ALAEN=0 or ALBEN=0)
2.
Wait until the ALAWF or ALBWF bit is set to enable write access to the alarm clock A or B
3.
Configure alarm clock A or B registers (ERTC_ALA/ERTC_ALASBS and
ERTC_ALB/ERTC_ALBSBS)
4.
Enable alarm clock A or B by setting ALAEN=1 or ALBEN=1
Note: If MASK1=0 in the ERTC_ALA or ERTC_ALB, the alarm clock can work normally only when
the DIVB value is at least equal to 3.
17.3.3 Periodic automatic wakeup
Periodic automatic wakeup unit is used to wake up ERTC from low power consumption modes
automatically. The period is programmed with the VAL[15: 0] bi (When WATCLK[2]=1, it is extended to
17 bits, and the wakeup counter value is VAL+216). When the wakeup counter value drops from the VAL
to zero, the WATF bit is set, and a wakeup event is generated, with the wakeup counter being reloaded
with the VAL value. An interrupt is also generated if a periodic wakeup interrupt is enabled.
The WATCLK[2: 0] bit can be used to select a wakeup timer clock, including ERTC_CLK/16,
ERTC_CLK/8, ERTC_CLK/4, ERTC_CLK/2 and ck_b (usually 1Hz). The cooperation between wakeup
timer clocks and wakeup counter values enable users to adjust the wakeup period freely.
To enable a periodic automatic wakeup, the following steps should be respected:
1.
Disable a periodic automatic wakeup by setting WATEN=0
2.
Wait until WATWF=1 to enable write access to the wakeup reload timer and WATCLK[2: 0]
3.
Configure the wakeup timer counter value and wakeup timer through VAL[15: 0] and WATCLK[2: 0]
bits
4.
Enable a timer by setting WATEN=1
Note: A wakeup timer is not affected by a system reset and low power consumption modes (Sleep,
Deepsleep and Standby modes).
Note: In DEBUG mode, if ERTC_CLK is selected as the wakeup timer, the counter for periodic wakeup
works normally..