After any MCU reset, the counter is stopped and reset to 0x0000, the modulus register is
set to 0x0000, and the prescaler is off. The external oscillator clock is selected as the
default clock source. To start the prescaler, write any value other than 0 to the Prescaler
Select field (RTC_SC2[RTCPS]).
The clock sources are software selectable: the external oscillator (XOSC), on-chip low
power oscillator (LPO), and bus clock. The RTC Clock Select field
(RTC_SC2[RTCLKS]) is used to select the desired clock source to the prescaler dividers.
If a different value is written to RTC_SC2[RTCLKS], the prescaler and CNTH and
RTC_CNTL counters are reset to 0x00.
RTC_SC2[RTCPS] and RTC_SC2[RTCLKS] select the desired divide-by value. If a
different value is written to RTC_SC2[RTCPS], the prescaler and RTCCNT counters are
reset to 0x00. The following table shows different prescaler period values.
Table 13-1. Prescaler period
RTCPS
32768Hz XOSC clock
source prescaler
period (RTCLKS = 00)
LPO clock (1 kHz)
source prescaler
period (RTCLKS = 01)
Bus clock (8 MHz)
source prescaler
period (RTCLKS = 10)
Bus clock (8 MHz)
source prescaler
period (RTCLKS = 11)
000
Off
Off
Off
Off
001
30.5176 µs
128 ms
125 ns
16 µs
010
61.0351 µs
256 ms
250 ns
32 µs
011
122.0703 µs
512 ms
500 ns
64 µs
100
244.1406 µs
1024 ms
1 µs
128 µs
101
488.28125 µs
2048 ms
2 µs
256 µs
110
976.5625 µs
100 ms
4 µs
12.5 µs
111
1.9531 ms
1 s
8 µs
125 µs
The RTC Modulo register (RTC_MODH and RTC_MODL) allows the compare value to
be set to any value from 0x0000 to 0xFFFF. When the counter is active, the counter
increments at the selected rate until the count matches the modulo value. When these
values match, the counter resets to 0x0000 and continues counting. The Real-Time
Interrupt Flag (RTC_SC1[RTIF]) is set whenever a match occurs. The flag sets on the
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 RTC_SC2[RTCPS] is
selected nonzero.
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 field
(RTC_SC1[RTIE]). RTC_SC1[RTIF] is cleared by writing a 1 to RTC_SC1[RTIF].
Chapter 13 Real-time counter (RTC)
MC9S08PA4 Reference Manual, Rev. 5, 08/2017
NXP Semiconductors
265
Summary of Contents for MC9S08PA4
Page 1: ...MC9S08PA4 Reference Manual Supports MC9S08PA4 Document Number MC9S08PA4RM Rev 5 08 2017 ...
Page 2: ...MC9S08PA4 Reference Manual Rev 5 08 2017 2 NXP Semiconductors ...
Page 22: ...MC9S08PA4 Reference Manual Rev 5 08 2017 22 NXP Semiconductors ...
Page 28: ...System clock distribution MC9S08PA4 Reference Manual Rev 5 08 2017 28 NXP Semiconductors ...
Page 150: ...Port data registers MC9S08PA4 Reference Manual Rev 5 08 2017 150 NXP Semiconductors ...
Page 196: ...Human machine interfaces HMI MC9S08PA4 Reference Manual Rev 5 08 2017 196 NXP Semiconductors ...
Page 224: ...Instruction Set Summary MC9S08PA4 Reference Manual Rev 5 08 2017 224 NXP Semiconductors ...
Page 232: ...Functional Description MC9S08PA4 Reference Manual Rev 5 08 2017 232 NXP Semiconductors ...
Page 258: ...FTM Interrupts MC9S08PA4 Reference Manual Rev 5 08 2017 258 NXP Semiconductors ...
Page 294: ...Functional description MC9S08PA4 Reference Manual Rev 5 08 2017 294 NXP Semiconductors ...
Page 398: ...Resets MC9S08PA4 Reference Manual Rev 5 08 2017 398 NXP Semiconductors ...
Page 400: ...MC9S08PA4 Reference Manual Rev 5 08 2017 400 NXP Semiconductors ...