![Geehy SEMICONDUCTOR APM32F030x4x6x8xC Скачать руководство пользователя страница 232](http://html1.mh-extra.com/html/geehy-semiconductor/apm32f030x4x6x8xc/apm32f030x4x6x8xc_user-manual_573629232.webp)
www.geehy.com Page 231
from the calendar counter. The time system of 24 hours and 12 hours can be
selected by TIMEFCFG bit of configuration register RTC_CTRL.
RTC updates the shadow register every two RTC_CLK cycles, and sets the flag
bit RSFLG. When waking up from shutdown or standby mode, generally the
shadow register will not be updated, which requires waiting for up to two
RTC_CLK cycles. The reset of shadow register is caused by system reset.
The shadow register is synchronized with f
APB1
.
The way to read the calendar can be selected by RCMCFG bit of configuration
register RTC_CTRL.
RCMCFG=0, read the calendar from the shadow register
In this mode, it is recommended that f
APB1
is greater than 7*fRTC_CLK. If f
APB1
is
too small, to ensure the normal reading of calendar value, it is required to read
the shadow register twice. If the calendar obtained twice is the same, the
calendar is read successfully.
After the shadow register is updated, the flag bit RSFLG will be set. The software
can read the calendar only after the bit RSFLG is set. Every time the calendar is
read, the RSFLG flag should be cleared manually.
When waking up from stop or standby mode, since the shadow register is not
updated, the RSFLG flag should be cleared immediately.
RCMCFG=1, read the calendar from the calendar counter
When f
APB1
is less than 7*fRTC_CLK or the system is woken from low-power
mode, it is recommended to read the calendar directly from the calendar counter.
If RSFLG bit is not set to 1 when reading the calender just at the stage of
calendar counter change, it is required to read the calendar twice. Therefore, it is
also recommended to read the calendar counter twice. When the read calendar
value is the same twice, it means that the calendar is read successfully.
Time Compensation
Due to seasonal changes, time compensation is sometimes needed to make it
more suitable for daily needs. RTC is integrated with time compensation unit and
its summer time flag. Users can choose whether to turn on time compensation
according to their own needs.
By setting STCCFG bit of the register RTC_CTRL, the summer time will increase
by 1 hour; by setting WTCCFG bit of the register RTC_CTRL, the winter time will
will decrease by 1. BAKP flag is used to record whether the summer time is set.
Programmable Alarm
As a real-time clock, RTC integrates alarm function, and it runs mainly through
alarm cock configuration register and alarm mask, in combination with calendar
counter.
Configure the alarm and alarm mask through the register RTC_ALRMA
、
RTC_ALRMASS, and the alarm mask informs RTC to pay attention to the time
period of the alarm. After the alarm function is enabled, the alarm will be
triggered only when the concerned time period reaches the set value. At this time,
the alarm flag is set. If the alarm interrupt is enabled, the interrupt processing will
be triggered.