AnsweredAssumed Answered

k60 rtc with external battery backup reinit

Question asked by Jason Scott on Nov 29, 2017
Latest reply on Dec 1, 2017 by Jason Scott

Hi everyone,


I am struggling with the RTC on a custom board that uses the k60.


i have the 3 volt battery connected to the VBAT pin (pin 42). A 32.8 KHz crystal connected across XTAL32 & EXTAL32.


I know that the hardware is fine, this design has been in place for a few years. We have recently upgraded to MQX 4.2 using the KDS IDE without processor expert.


I am struggling with the bsp settings for the RTC. The RTC is re-initializing every time upon bootup. I would assume there is a way to have it check to see if the RTC is already running. which under the _RTC_INIT() function, it appears to do....


int32_t _rtc_init
/* [IN] param identifying init operations */
void* param
{ /* Body */
int32_t result = MQX_OK;
RTC_MemMapPtr rtc = RTC_BASE_PTR;

/* Check if the time is invalid */
if (rtc->SR & RTC_SR_TIF_MASK)
rtc->SR &= ~RTC_SR_TCE_MASK; /* disable rtc timer - enable write access */
rtc->TAR = 0xFFFFFFFF; /* e2574: RTC: Writing RTC_TAR[TAR] = 0 does not disable RTC alarm */

/* if TIF reading TSR return zero and we must set TSR to one */
rtc->TSR = 1; /* this clear SR flags TIF, TOF */
/* Update alarm time & alarm period */

alarm_time = 0;
alarm_period = 0;
} /* End if*/

/* Check if RTC counter or OSC for RTC is not started */
if( !(rtc->SR & RTC_SR_TCE_MASK) || !(rtc->CR & RTC_CR_OSCE_MASK) )
/* recommended 125 ms delay for oscillator start */
} /* End if */

return result;
} /* Endbody */


From my understanding the RTC should continue to run off of the battery power when the main power is shut off. The only setting that is 100% clear is to set BSPCFG_ENABLE_RTCDEV to 1. 


Does anyone have an idea on where i should direct my attention to?


Thanks for you time,