9 years, 5 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 2014

Sorry 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
	}	
posted by David Alain 22 Feb 2015
Be the first to answer this question.