RTC resetting whenever power to the MCU is lost on R7FA6E10F2CFP

I am having an issue with the RTC. When I lose power the RTC resets every time. I use the 'g_rtc0.p_api->open(g_rtc0.p_ctrl, g_rtc0.p_cfg);' API, but I am still not able to retain the correct date and time. 

  • Hello,

    Thanks for reaching out Renesas Engineering Community!

    After reset occurs you should initialize RTC with open() function as you do but you should also call  this API:

    fsp_err_t 	R_RTC_CalendarTimeSet (rtc_ctrl_t *const p_ctrl, rtc_time_t *const p_time)

    In order to set parameters like year, day month. Also something else that you could do is to save the current date in a block of data flash in order to read the memory addresses  and keep the last date that reset occurred.

    Find here attached an example of how to do that. In this example I have configured RTC timer ,initialized it , set CallendarTime and also have a timer which is configured to get the current date and save it to data flash every second.

    Please notice that this example is for RA6M3 since I did not have available RA6E1. So you should also check the memory map for the data flash of RAE1.

    Hope it helps!

    Best Regards,



  • Thank you for the detailed reply. I just have one question with regards to this: What happens if you lose power to the system for an extended period of time? How do you ensure that the correct time is loaded when you regain power? I am not putting two and two together with regards to that.

  • Hello Liam,

    As far I can understand you are asking , if the contents of the flash and the date you save there will be valid, even if you lose power for an extended period of time right?

    Thank you!

    Best Regards,


Reply Children
No Data