Chapter 12
Real Time Clock (RTC)
XII - 18 RTC Operation
Alarm Interrupt Setup Example
The following is an example to generate the Alarm 0 interrupt at 10:23 on Saturday with the RTC function.
Set the initial time to "01:01:00 (Thursday)" in 24-hour display mode.
The setup procedure and the description of each step are shown below.
Step Setting Symbol Description
1 RTC stops RTCCTR Set the CLKEN bit to "0".
2 Alarm interrupt disabled RTCAL0IRQ Set the AL0IRQSET bit to "0".
3 Display mode setting RTCCTR Set the HDMD bit to "0".
4
Clock data setting - Set the clock data to "01:01:00 (Thursday)" using the
following registers.
RTCWD Set it to "0x04".
RTCHD Set it to "0x01".
RTCMID Set it to "0x01".
5 Alarm interrupt enabled RTCAL0IRQ Set the AL0IRQSET bit to "1".
6
Alarm detection enabled RTCAL0IRQ Set the AL0IRQWEN, AL0IRQHEN, and AL0IRQMIEN
bits to "1".
7
Alarm time setting - Set the alarm time to "10:23 (Saturday)" using the fol-
lowing registers.
AL0IRQW Set it to "0x6".
AL0IRQH Set it to "0x10".
AL0IRQMI Set it to "0x23".
8 All maskable interrupts disabled PSW * Set the IE bit to "0".
9
Interrupt level setting PERI0ICR * Set the PERI0LV1-0 bits to "00".
Clear the corresponding interrupt request bit of
PERI0DT register, if it may have already been set.
Refer to [3.1.5 Set up procedure for Interrupt control
register for peripheral function group]
10
Alarm 0 Interrupt enabled PERI0EN * Set the PERI0EN5 bit to "1".
Refer to [Chapter 3 Interrupts]
11 Maskable interrupts enabled PSW * Set the IE bit to "1".
12
RTC starts RTCCTR Set the CLKEN bit to "1".
The RTC starts.
* For PSW, refer to [Chapter 2 CPU].
For PERI0ICR and PERI0EN, refer to [Chapter 3 Interrupts]