Skip to content

Commit cf59124

Browse files
jwetzelldeadprogram
authored andcommitted
runtime/esp32s3: wait for TIMG0 update register to clear before reading timer registers
1 parent 1f114b2 commit cf59124

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/runtime/runtime_esp32sx.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ func initTimer() {
5858
func ticks() timeUnit {
5959
// First, update the LO and HI register pair by writing any value to the
6060
// register. This allows reading the pair atomically.
61-
esp.TIMG0.T0UPDATE.Set(0)
61+
esp.TIMG0.T0UPDATE.Set(1)
62+
for esp.TIMG0.T0UPDATE.Get() != 0 {
63+
// Register is cleared when the update is complete.
64+
}
6265
// Then read the two 32-bit parts of the timer.
6366
return timeUnit(uint64(esp.TIMG0.T0LO.Get()) | uint64(esp.TIMG0.T0HI.Get())<<32)
6467
}

0 commit comments

Comments
 (0)