English
Language : 

SH7708 Datasheet, PDF (346/625 Pages) Renesas Technology Corp – SuperH™ RISC engine
12.3.4 Alarm Function
Figure 12.4 shows how to use the alarm function.
Alarms can be generated using seconds, minutes, hours, day of the week, date, month, or any
combination of these. Set the ENB bit (bit 7) in the register on which the alarm is placed to 1, and
then set the alarm time in the lower bits. Clear the ENB bit in the register on which the alarm is
placed to 0.
When the clock and alarm times match, a 1 is set in the AF bit (bit 0) in RCR1. Alarm detection
can be checked by reading this bit, but normally it is done by interrupt. If 1 is placed in the AIE
bit (bit 3) in RCR1, an interrupt is generated when an alarm occurs.
Clock running
Temporarily disable interrupts (clear AIE bit
Clear alarm interrupt in RCR1 register to 0) to prevent erroneous
interruption
Set alarm time
Set alarm interrupt
Clear alarm flag
Monitor alarm time
(wait for interrupt or
check alarm flag)
When interrupts are used, enable interrupts
(set AIE bit in RCR1 register to 1)
Flag must be reset (by clearing AF bit in RCR1
register to 0) since it was set during alarm
time setting
Figure 12.4 Using the Alarm Function
332