AnsweredAssumed Answered

RTC seconds not updated properly

Question asked by Cecylia Wati on Jul 10, 2015
Latest reply on Jul 21, 2015 by Cecylia Wati

I'm monitoring the behavior of the second and TPR (Prescaler) of this K22F board.

 

I notice that sometimes the Second register (HW_RTC_TSR_RD) hasn't been updated when the Prescaler (HW_RTC_TPR_RD) has.

 

Code snippet is as follows:

 

static uint32_t last_sec = 0, last_tpr = 0;

dummy_tpr = HW_RTC_TPR_RD(RTC_BASE);

current_tpr = HW_RTC_TPR_RD(RTC_BASE);

while (dummy_tpr != current_tpr) {

          dummy_tpr = HW_RTC_TPR_RD(RTC_BASE);

          current_tpr = HW_RTC_TPR_RD(RTC_BASE);

}

 

dummy_rtc = HW_RTC_TSR_RD(RTC_BASE);

current_sec = HW_RTC_TSR_RD(RTC_BASE);

while (dummy_tpr != current_tpr) {

     dummy_rtc = HW_RTC_TSR_RD(RTC_BASE);

     current_sec = HW_RTC_TSR_RD(RTC_BASE);

}

 

if ((last_sec != 0) && (last_tpr != 0)) {

     if ((last_sec == current_sec) && (last_tpr > current_tpr)) {

          //This is disaster...

          //STOP HERE in DEBUGGER

     }

}

last_sec = current_sec;

last_tpr = current_tpr;

 

Note: I re-read registers per this entry:

RTC counters behavior (seconds and prescaler registers)

 


I notice that these cases happen sometimes

first read:
second: 0x2, tpr: 0x7FFF

then next read:

second: 0x2, tpr: 0x0  ----> or sometimes even 0x1

 

Which tells me that most likely TPR has incremented while second hasn't?

Is this a known HW problem? Or, did I miss some settings?

 

 

 

 

Any help is appreciated.  Thanks.

Outcomes