GD32W51x User Manual
401
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 is set.
16.3.5.
Configurable periodic auto-wakeup counter
In the RTC block, there is a 16-bit down counter designed to generate periodic wakeup flag.
This function is enabled by set the WTEN to 1 and can be running in power saving mode.
Two clock sources can be chose for the down counter:
1)
RTC clock divided by 2/4/8/16
Assume RTC clock comes from LXTAL (32.768 KHz), this can periodically assert wakeup
interrupt from 122us to 32s under the resolution down to 61us.
2)
Internal clock ck_spre
Assume ck_spre is 1Hz, this can periodically assert wakeup interrupt from 1s to 36 hours
under the resolution down to 1s.
-
WTCS[2:1] = 0b10.This will make period to be 1s to 18 hours
-
WTCS[2:1] = 0b11.This will make period to be 18 to 36 hours
When this function is enabled, the down counter is running. When it reaches 0, the WTF flag
is set and the wakeup counter is automatically reloaded with RTC_WUT value.
When WTF asserts, software must then clear it.
If WTIE is set and this counter reaches 0, a wakeup interrupt will make system exit from the
power saving mode. System reset has no influence on this function.
16.3.6.
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 below steps 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.
After Backup domain reset, some of the RTC registers are write-protected: RTC_TIME,
RTC_DATE, RTC_PSC, RTC_COSC,
RTC_HRFC
,
RTC_SHIFTCTL, the bit INITM in
RTC_ICSR and the bits CS, S1H ,A1H
,
REFEN in RTC_CTL.
The registers protected by INITPRIV are write-protected by the INIT KEY.