![GigaDevice Semiconductor GD32E23 Series Скачать руководство пользователя страница 202](http://html.mh-extra.com/html/gigadevice-semiconductor/gd32e23-series/gd32e23-series_user-manual_2225794202.webp)
GD32E23x User Manual
202
If a field is masked, the field is considered as matched in logic. If all the fields have been
masked, the Alarm Flag will assert 3 RTC clock later after ALRMxEN (x=0) is set.
13.3.5.
RTC initialization and configuration
RTC register write protection
BKPWEN bit in the PMU_CTL register is cleared in default, so writing to RTC registers
needs setting BKPWEN bit ahead of time.
After power-on reset, most of RTC registers are write protected. Unlocking this protection is
the first step before writing to them.
Following steps below will unlock the write protection:
1.
Write ‘0xCA’ into the RTC_WPK register
2.
Write ‘0x53’ into the RTC_WPK register
Writing a wrong value to RTC_WPK will make write protection valid again. The state of write
protection is not affected by system reset. Following registers are writing protected but
others are not:
RTC_TIME,
RTC_DATE,
RTC_CTL,
RTC_STAT,
RTC_PSC,
RTC_ALRMxTD,
RTC_SHIFTCTL, RTC_HRFC, RTC_ALRMxSS
Calendar initialization and configuration
The prescaler and calendar value can be programmed by the following steps:
1.
Enter initialization mode (by setting INITM=1) and polling INITF bit until INITF=1.
2.
Program both the asynchronous and synchronous prescaler factors in RTC_PSC
register.
3.
Write the initial calendar values into the shadow calendar registers (RTC_TIME and
RTC_DATE), and use the CS bit in the RTC_CTL register to configure the time format
(12 or 24 hours).
4.
Exit the initialization mode (by setting INITM=0).
About 4 RTC clock cycles later, real calendar registers will load from shadow registers and
calendar counter restarts.
Note:
Reading calendar register (BPSHAD=0) after initialization, software should confirm the
RSYNF bit to 1.
YCM flag indicates whether the calendar has been initialized by checking the year field of
calendar.
Daylight saving Time
RTC unit supports daylight saving time adjustment through S1H, A1H and DSM bit.