13.4.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
32765
32766
32767
0
1
2
3
4
RTIF
32767
32767
32767
32766
32766
32766
32766
32766
32766
RTCCNT
RTCPS = 01b
RTC Clock
RTCPS = 01b
RTCMOD
16-bit modulo
Figure 13-2. RTC counter overflow example
In the above example, the external clock source is selected. 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.
13.5 Initialization/application information
This section provides example code to give some basic direction to a user on how to
initialize and configure the RTC module. The example software is implemented in C
language.
The example below shows how to implement time of day with the RTC using the XOSC
clock source to achieve the lowest possible power consumption.
Example: 13.5.1 Software calendar implementation in RTC ISR
Initialization/application information
MC9S08PA4 Reference Manual, Rev. 5, 08/2017
266
NXP Semiconductors
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 ...