Datasheet

transition from the modulo value to 0x0000. The modulo value written to RTC_MODH
and RTC_MODL is latched until the RTC counter overflows or the RTC_SC2[RTCPS] is
selected non-zero.
The RTC allows for an interrupt to be generated whenever RTC_SC1[RTIF] is set. To
enable the real-time interrupt, set the real-time interrupt enable bit (RTC_SC1[RTIE]).
RTC_SC1[RTIF] is cleared by writing a 1 to RTC_SC1[RTIF].
The RTC also allows an output to external pinout by toggling the level. The
(RTC_SC1[RTCO] bit must be set to enable toggling external pinout. The level depends
on the previous state of the pinout when the counter overflows if this function is active.
14.5.1 RTC operation example
This section shows an example of the RTC operation as the counter reaches a matching
value from the modulo register.
32766 32766
XOSC (32768Hz)
RTCLKS = 00b
RTC Clock
RTCPS =
32765
RTCCNT
RTCPS =
32766 32767 0 1 2 3 4
RTIF
RTCMOD
32767
16-bit modulo
32767 32767 32766
32766
32766 32766 32766 32766
RTCO
001b
001b
Figure 14-8. RTC counter overflow example
In the above example, the selected clock source is the external clock source. The
prescaler is set to RTC_SC2[RTCPS] = 001b or passthrough. The actual modulo value
used by 16-bit comparator is 32767, when the modulo value in the RTC_MODH and
RTC_MODL registers is set to 32766. When the counter, RTC_CNTH and RTC_CNTL,
reaches the modulo value of 32767, the counter overflows to 0x00 and continues
counting. The modulo value is updated by fetching from RTC_MODH and RTC_MODL
registers. The real-time interrupt flag, RTC_SC1[RTIF], sets when the counter value
changes from 0x7FFF to 0x0000. The RTC_SC1[RTCO] toggles as well when the
RTC_SC1[RTIF] is set.
Chapter 14 Real-time counter (RTC)
MC9S08PA60 Reference Manual, Rev. 1, 9/2012
Freescale Semiconductor, Inc. 401