read_RTC_time:
WRITE_RTC_REG(RTC_CNTL_TIME_UPDATE_REG, RTC_CNTL_TIME_UPDATE_S, 1,1)
wait_RTC_update:
READ_RTC_REG(RTC_CNTL_TIME_UPDATE_REG, RTC_CNTL_TIME_VALID_S, 1)
jumpr wait_RTC_update, 0, eq
READ_RTC_REG(RTC_CNTL_TIME0_REG+2, 0, 16)
move r1, last_measurement_time
st r0, r1, 0
The value I'm getting in R0 looks pretty random. On the other hand, if I do:
uint32_t* time0 = (uint32_t *) 0x3FF48010;
printf("last_measurement_time: %X, current_time: %X\n", ulp_last_measurement_time & 0xFFFF, (*time0 & 0xFFFF0000) >> 16);
It seems like I can read the RTC timer fine from the main processor. Current_time makes sense, whereas ulp_last_measurement_time is garbage. What am I doing wrong?