runtime/esp32s3: wait for TIMG0 update register to clear before reading timer registers

This commit is contained in:
Joel Wetzell
2026-04-21 12:55:57 -05:00
committed by Ron Evans
parent 1f114b2acf
commit cf5912412d
+4 -1
View File
@@ -58,7 +58,10 @@ func initTimer() {
func ticks() timeUnit {
// First, update the LO and HI register pair by writing any value to the
// register. This allows reading the pair atomically.
esp.TIMG0.T0UPDATE.Set(0)
esp.TIMG0.T0UPDATE.Set(1)
for esp.TIMG0.T0UPDATE.Get() != 0 {
// Register is cleared when the update is complete.
}
// Then read the two 32-bit parts of the timer.
return timeUnit(uint64(esp.TIMG0.T0LO.Get()) | uint64(esp.TIMG0.T0HI.Get())<<32)
}