I'm looking at the _rtc_get_time source code in srtc.c for MQX 4.1.0 (I'm using it in a VF65GS10 project) and believe I may have found a bug. Here is the code:
uint32_t tmp = 0;
*time = tmp;
tmp = (snvs->LPSRTCMR << 17) | (snvs->LPSRTCLR >> 15) ;
} while (tmp != *time);
This is apparently trying to achieve a coherent read of the two RTC registers by continually reading them until it obtains two consecutive identical values. However, this code will always go through the do/while only one time, because of the way the tmp variable is initialized. To operate correctly the first line should instead be:
uint32_t tmp = (snvs->LPSRTCMR << 17) | (snvs->LPSRTCLR >> 15) ;
Am I missing something here?