Question
issue of reading RTC
Posted on June 06, 2012 at 08:48
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 readSo the fetched values of RTC->CNTH and RTC->CNTL are now wrongWhat is the preferred method to avoid this problem ?I currently useu32 rtc0, rtc1;do{ 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 pleaseThanks, Mark