mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
runtime/esp32s3: wait for TIMG0 update register to clear before reading timer registers
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user