mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 18:53:29 +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 {
|
func ticks() timeUnit {
|
||||||
// First, update the LO and HI register pair by writing any value to the
|
// First, update the LO and HI register pair by writing any value to the
|
||||||
// register. This allows reading the pair atomically.
|
// 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.
|
// Then read the two 32-bit parts of the timer.
|
||||||
return timeUnit(uint64(esp.TIMG0.T0LO.Get()) | uint64(esp.TIMG0.T0HI.Get())<<32)
|
return timeUnit(uint64(esp.TIMG0.T0LO.Get()) | uint64(esp.TIMG0.T0HI.Get())<<32)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user