Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 11 months ago.
RTC reset issue on FRDM-K64F
Hi,
I'm running a RTC code in a FRDM-K64F that is based on Erik Olieman code http://developer.mbed.org/users/Sissors/code/RTC/.
My project is all in C instead of C++, and I'm using the mbed-src from github for all features.
My problem is:
I configure the RTC and it works properly until a reset occur, because when a reset occur all the RTC registers are cleared to their default values, so it lose all configured and counted date/time.
Is there any way to do not lose this values? Did someone have the same problem?
David,
As long as there is no power cycle, the K64F does keep time after a reset.
...kevin
posted by Kevin Braun 21 Nov 2014Sorry for delay
I could solve this issue :D
The main problem was the way I get the RTC value on my initialization code.
I solve the problem using this code:
RTC initialization code
//Initialize the RTC, if it has not been initialized before the last reset if((CLOCK_SYS_GetRtcGateCmd(0) == false) || (RTC_HAL_IsOscillatorEnabled(RTC_BASE) == false)){ //Disable the flags cleaning on software reset RTC_HAL_SoftwareResetFlagClear(RTC_BASE); sec = time(NULL); //Configure the RTC and reset count value }else{ sec = rtc_read(); //Read RTC count value without modifying any configuration }