
RTC_B Operation
The user-programmable alarm event sources the real-time clock interrupt, RTCAIFG. Setting RTCAIE
enables the interrupt. In addition to the user-programmable alarm, the RTC_B module provides for an
interval alarm that sources real-time clock interrupt, RTCTEVIFG. The interval alarm can be selected to
cause an alarm event when RTCMIN changed or RTCHOUR changed, every day at midnight (00:00:00)
or every day at noon (12:00:00). The event is selectable with the RTCTEV bits. Setting the RTCTEVIE bit
enables the interrupt.
The RTCRDY bit sources the real-time clock interrupt, RTCRDYIFG, and is useful in synchronizing the
read of time registers with the system clock. Setting the RTCRDYIE bit enables the interrupt.
RT0PSIFG can be used to generate interrupt intervals selectable by the RT0IP bits. RT0PS is sourced
with low-frequency oscillator clock at 32768 Hz, so intervals of 16384 Hz, 8192 Hz, 4096 Hz, 2048 Hz,
1024 Hz, 512 Hz, 256 Hz, or 128 Hz are possible. Setting the RT0PSIE bit enables the interrupt.
RT1PSIFG can be used to generate interrupt intervals selectable by the RT1IP bits. RT1PS is sourced
with the output of RT0PS, which is 128 Hz (32768/256 Hz). Therefore, intervals of 64 Hz, 32 Hz, 16 Hz,
8 Hz, 4 Hz, 2 Hz, 1 Hz, or 0.5 Hz are possible. Setting the RT1PSIE bit enables the interrupt.
NOTE:
Changing RT0IP or RT1IP
Changing the settings of the interrupt interval bits RT0IP or RT1IP while the corresponding
pre-scaler is running or is stopped in a non-zero state can result in setting the corresponding
interrupt flags.
The RTCOFIFG bit flags a failure of the 32-kHz crystal oscillator. Its main purpose is to wake up the CPU
from LPM3.5 if an oscillator failure occurs.
13.2.4.1 RTCIV Software Example
The following software example shows the recommended use of RTCIV and the handling overhead. The
RTCIV value is added to the PC to automatically jump to the appropriate routine.
The numbers at the right margin show the necessary CPU cycles for each instruction. The software
overhead for different interrupt sources includes interrupt latency and return-from-interrupt cycles, but not
the task handling itself.
; Interrupt handler for RTC interrupt flags.
RTC_HND
; Interrupt latency
6
ADD &RTCIV,PC
; Add offset to Jump table
3
RETI
; Vector 0: No interrupt
5
JMP RTCRDYIFG_HND
; Vector 2: RTCRDYIFG
2
JMP RTCTEVIFG_HND
; Vector 4: RTCTEVIFG
2
JMP RTCAIFG_HND
; Vector 6: RTCAIFG
5
JMP RT0PSIFG_HND
; Vector 8: RT0PSIFG
5
JMP RT1PSIFG_HND
; Vector A: RT1PSIFG
5
JMP RTCOFIFG_HND
; Vector C: RTCOFIFG
5
RETI
; Vector E: Reserved
5
RTCRDYIFG_HND
; Vector 2: RTCRDYIFG Flag
...
; Task starts here
RETI
; Back to main program
5
RTCTEVIFG_HND
; Vector 4: RTCTEVIFG Flag
...
; Task starts here
RETI
; Back to main program
5
RTCAIFG_HND
; Vector 6: RTCAIFG Flag
...
; Task starts here
RETI
; Back to main program
5
RT0PSIFG_HND
; Vector 8: RT0PSIFG Flag
386
Real-Time Clock B (RTC_B)
SLAU272C – May 2011 – Revised November 2013
Copyright © 2011–2013, Texas Instruments Incorporated