S32K312: RTC- Preserving RTC counter value from getting resets once after every wakeup

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K312: RTC- Preserving RTC counter value from getting resets once after every wakeup

S32K312: RTC- Preserving RTC counter value from getting resets once after every wakeup

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.

krshvivek_0-1736931950041.png

wake_up_event will be incremented if MCU reset reason is wakeup as shown below.

krshvivek_1-1736932038455.png

 

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".

krshvivek_2-1736932277658.png

 

 Any other alternatives other than this approach is highly appreciated.

Thanks in advance!

 

Attachments
No ratings
Version history
Last update:
3 weeks ago
Updated by: