12.07.2015 Views

SuperH (SH) 64-Bit RISC Series SH-5 System Architecture, Volume ...

SuperH (SH) 64-Bit RISC Series SH-5 System Architecture, Volume ...

SuperH (SH) 64-Bit RISC Series SH-5 System Architecture, Volume ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

PRELIMINARY DATA168 OperationIf a carry occurs while the time is being read, the correct time will not be obtainedand the read must be repeated. The procedure for reading the time without usinginterrupts is shown in (a), and the procedure using carry interrupts in (b). Themethod without using interrupts is normally used to keep the program simple.7.3.3 Alarm functionThe use of the alarm function is illustrated in Figure 17.Clock runningDisable alarm interruptsSet alarm timeClear alarm flagEnable alarm interruptsMonitor alarm time(Wait for interrupt or checkalarm flag)Clear RCR1.AIE to prevent erroneous interruptsBe sure to reset the flag as it may have beenset during alarm time settingSet RYR1.AIE to 1Figure 17: Example of use of alarm functionAn alarm can be generated by the second, minute, hour, day-of-week, day, or monthvalue, or a combination of these. Write 1 to the ENB bit in the alarm registersinvolved in the alarm setting, and set the alarm time in the lower bits. Write 0 to theENB bit in registers not involved in the alarm setting.D R A FTWhen the counter and the alarm time match, RTC.RCR1.AF is set to 1. Alarmdetection can be confirmed by reading this bit, but normally an interrupt is used.If 1 has been written to RTC.RCR1.AIE, an alarm interrupt is generated in the eventof alarm, enabling the alarm to be detected.The alarm flag remains set while the counter and alarm time match. If the alarmflag is cleared by writing 0 during this period, it will therefore be set againimmediately afterward. This needs to be taken into consideration when writing theprogram.<strong>SuperH</strong>, Inc.<strong>SH</strong>-5 <strong>System</strong> <strong>Architecture</strong>, <strong>Volume</strong> 1: <strong>System</strong> 05-SA-10001 v1.0

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!