AnsweredAssumed Answered

issue of reading RTC

Question asked by ather.m on Jun 6, 2012
Latest reply on Jun 6, 2012 by Clive One
Hi All,

I am wondering if there is an internal interlock that prevents the RTC from being updated while the registers (RTC->CNTH and RTC->CNTL) are being read.

There is a situation where
     RTC->CNTH has been read
     RTC then updates rolling RTC->CNTH and RTC->CNTL over
     RTC->CNTL is then read

So the fetched values of RTC->CNTH and RTC->CNTL are now wrong

What is the preferred method to avoid this problem ?

I currently use

u32 rtc0, rtc1;
        rtc0 = 0; rtc0 = RTC->CNTH << 16; rtc0 |= RTC->CNTL;// get two, same RTC counts
        rtc1 = 0; rtc1 = RTC->CNTH << 16; rtc1 |= RTC->CNTL;
while(rtc0 != rtc1);

which is a bit bone headed...

Thoughts please

Thanks, Mark