![ARTERY AT32F425 Series Reference Manual Download Page 288](http://html1.mh-extra.com/html/artery/at32f425-series/at32f425-series_reference-manual_2977590288.webp)
AT32F425
Series Reference Manual
2022.03.30
Page 288
Ver 2.01
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
Periodica 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 betwee 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)
17.3.4 ERTC calibration
Smooth digital calibration:
Smooth digital calibration has a higher and well-distributed performance than the coarse digital
calibration. The calibration is performed by increasing or decreasing ERTC_CLK in an evenly manner.
The smooth digital calibration period is around 2
20
ERTC_CLK (32 seconds) when the ERTC_CLK is
32.768 kHz. The DEC[8: 0] bit specifies the number of pulses to be masked during the 2
20
ERTC_CLK
cycles. A maximum of 511 pulses can be removed. When the ADD bit is set, 512 pulses can be inserted
during the 2
20
ERTC_CLK cycles. When DEC[8: 0] and ADD are sued together, a deviation ranging from
-511 to +512 ERTC_CLK cycles can be added during the 2
20
ERTC_CLK cycles.
The effective calibrated frequency (F
SCAL)
:
F
SCAL
= F
ERTC_CLK
× [ 1 +
512
x
ADD
DEC
2
DEC
512
x
ADD
20
]
When the divider A is less than 3, the calibration operates as if ADD was equal to 0. The divider B value
should be reduced so that each second is accelerated by 8 ERTC_CLK cycles, which means that 256
ERTC_CLK cycles are added every 32 seconds. When DEC[8: 0] and ADD are sued together, a
deviation ranging from -255 to +256 ERTC_CLK cycles can be added during the 2
20
ERTC_CLK cycles.
At this point, the effective calibrated frequency (F
SCAL)
F
SCAL
= F
ERTC_CLK
× [ 1 +
256
DEC
2
DEC
256
20
]
It is also possible to select 8 or 16-second digital calibration period through the CAL8 and CAL16 bits.
The 8-second period takes priority over 16-second. In other words, when both 8-second and 16-second
are enabled, 8-second calibration period prevails.
The CALUPDF flag in the ERTC indicates the calibration status. During the configuration of ERTC_SCAL
registers, the CALUPDF bit is set, indicating that the calibration value is being updated; Once the
calibration value is successfully applied, this bit is cleared automatically, indicating the completion of the
calibration value update.