diff --git a/src/runtime/runtime_mimxrt1062_clock.go b/src/runtime/runtime_mimxrt1062_clock.go index 92a6fe05..a262fe2c 100644 --- a/src/runtime/runtime_mimxrt1062_clock.go +++ b/src/runtime/runtime_mimxrt1062_clock.go @@ -9,7 +9,7 @@ import ( // Core, bus, and peripheral clock frequencies (Hz) const ( CORE_FREQ = 600000000 // 600 MHz - OSC_FREQ = 100000 // 100 kHz (see note below) + SYSTICK_FREQ = 100000 // 100 kHz (see note below) _ // ----------- AHB_FREQ = 600000000 // 600 MHz CAN_FREQ = 40000000 // 40 MHz @@ -65,7 +65,7 @@ var ( } ) -// Note about OSC_FREQ from Teensyduino (cores/teensy4/startup.c): +// Note about SYSTICK_FREQ from Teensyduino (cores/teensy4/startup.c): // // | ARM SysTick is used for most Ardiuno timing functions, delay(), millis(), // | micros(). SysTick can run from either the ARM core clock, or from an diff --git a/src/runtime/runtime_mimxrt1062_time.go b/src/runtime/runtime_mimxrt1062_time.go index 57390650..0539ec11 100644 --- a/src/runtime/runtime_mimxrt1062_time.go +++ b/src/runtime/runtime_mimxrt1062_time.go @@ -11,15 +11,14 @@ import ( type timeUnit int64 -const ( - SYST_FREQ = OSC_FREQ // HW divides 24 MHz XTALOSC down to 100 kHz - lastCycle = SYST_FREQ/1000 - 1 - microsPerCycle = 1000000 / SYST_FREQ +const ( // HW divides 24 MHz XTALOSC down to 100 kHz + lastCycle = SYSTICK_FREQ/1000 - 1 + microsPerCycle = 1000000 / SYSTICK_FREQ ) const ( - PIT_FREQ = OSC_FREQ // HW divides 24 MHz XTALOSC down to 100 kHz - pitMicrosPerCycle = 1000000 / PIT_FREQ + PIT_FREQ = PERCLK_FREQ + pitCyclesPerMicro = PIT_FREQ / 1000000 pitSleepTimer = 0 // x4 32-bit PIT timers [0..3] ) @@ -88,7 +87,7 @@ func sleepTicks(duration timeUnit) { curr := ticks() last := curr + duration for curr < last { - cycles := timeUnit((last - curr) * pitMicrosPerCycle) + cycles := timeUnit((last - curr) / pitCyclesPerMicro) if cycles > 0xFFFFFFFF { cycles = 0xFFFFFFFF }