
Rev. 1.00
374 of 486
July 31, 2018
32-Bit Arm
®
Cortex
®
-M0+ MCU
HT32F50231/HT32F50241
17 Real T
ime Clock (RTC)
17 Real T
ime Clock (RTC)
Functional Descriptions
RTC Related Register Reset
The RTC registers can only be reset by either a V
DD15
Domain power on reset, POR15, or by a
PWRCU software reset by setting the PWCURST bit in the PWRCR register. Other reset events
have no effect to clear the RTC registers.
Low Speed Clock Configuration
The default RTC clock source, CK_RTC, is derived from the LSI oscillator. The CK_RTC clock
can be derived from either the external 32,768 Hz crystal oscillator, named the LSE oscillator,
or the internal 32 kHz RC oscillator named the LSI oscillator, by setting the RTCSRC bit in the
RTCCR register. A prescaler is provided to divide the CK_RTC by a ratio ranged from 2
0
to 2
15
determined by the RPRE [3:0] field. For instance, setting the prescaler value RPRE [3:0] to 0xF will
generate an exact 1 Hz CK_SECOND clock if the CK_RTC clock frequency is equal to 32,768 Hz.
The LSE oscillator can be enabled by the LSEEN control bits in the RTCCR register. In addition,
the LSE oscillator startup mode can be selected by configuring the LSESM bit in the RTCCR
register. This enables the LSE oscillator to have either a shorter startup time or a lower power
consumption, both of which are traded off depending upon specific application requirements. An
example of the startup time and the power consumption for different startup modes are shown in
the accompanying table for reference.
Table 39. LSE Startup Mode Operating Current and Startup Time
Startup Mode
LSESM Setting
in the RTCCR Register Operating Current
Startup Time
Normal startup
0
2.0 μA
Above 500 ms
Fast startup
1
3.5 μA
Below 300 ms
@ V
DD
= 3.3 V and LSE clock = 32,768 Hz; these values are only for reference, actual values are
dependent on the specification of the external 32.768 kHz crystal.
RTC Counter Operation
The RTC provides a 24-bit up-counter which increments at the falling edge of the CK_SECOND
clock and whose value can be read from the RTCCNT register asynchronously via the APB bus.
A 24-bit compare register, RTCCMP, is provided to store the specific value to be compared with
the RTCCNT content. This is used to define a pre-determined time interval. When the RTCCNT
register content is equal to the RTCCMP register value, the match flag CMFLAG in the RTCSR
register will be set by hardware and an interrupt or wakeup event can be sent according to the
corresponding enable bits in the RTCIWEN register. The RTC counter will be either reset to zero
or keep counting when the compare match event occurs, dependent upon the CMPCLR bit in
the RTCCR register. For example, if the RPRE [3:0] is set to 0xF, the RTCCMP register content
is set to a decimal value of 60 and the CMPCLR bit is set to 1, then the CMFLAG bit will be
set every minute. In addition, the OVFLAG bit in the RTCSR register will be set when the RTC
counter overflows. A read operation on the RTCSR register clears the status flags including the
CSECFLAG, CMFLAG and OVFLAG bits.
Interrupt and Wakeup Control
The falling edge of the CK_SECOND clock causes the CSECFLAG bit in the RTCSR register
to be set and generates an interrupt if the corresponding interrupt enable bit, CSECIEN, in the
RTCIWEN register is set. The wakeup event can also be generated to wake up the HSI / HSE