Hi team,
First let me explain about the code about what it does.
=======================================
1) From POR, LED starts blinking - In this state RTC won't be initialized.
2) Once SW5 is pressed in S32K312 EVB - RTC will be initialized before MCU goes to sleep.
3) RTCCNT will be incrementing during sleep
4) Once SW6 is pressed , MCU wakes from the sleep and we could able see the updated RTC time and date.
WAR(Work Around)done to keep RTC alive during sleep:
=======================================
Tried to test the RTC with sleep mode, observed that RTCCNT value is getting reset once after every wakeup. So that time and date was not able to preserve the value.
In order to avoid this, I have done two workarounds to solve this RTCCNT value reset issue.
1) RTC will not be initialized for if MCU wakeup from the sleep - Made the check to initialize when MCU is not from the wakeup before it goes to sleep.
wake_up_event will be incremented if MCU reset reason is wakeup as shown below.
2) Updating "Rtc_Ip_u32ChState" array variable for "ticksPerSecond" member in "Rtc_Ip.c" file manually after the code generation is completed.
Note: With auto generated code the value of "ticksPerSecond "will be "0".
Any other alternatives other than this approach is highly appreciated.
Thanks in advance!