teensy40: fix PIT clock, which actually uses 24 MHz OSC
see: https://forum.pjrc.com/threads/63979-What-peripherals-are-affected-by-the-undocumented-24-MHz-OSC-circuit-on-Teensy-4-0
Этот коммит содержится в:
родитель
f93b28057a
коммит
0d9c46b59e
2 изменённых файлов: 8 добавлений и 9 удалений
|
@ -9,7 +9,7 @@ import (
|
||||||
// Core, bus, and peripheral clock frequencies (Hz)
|
// Core, bus, and peripheral clock frequencies (Hz)
|
||||||
const (
|
const (
|
||||||
CORE_FREQ = 600000000 // 600 MHz
|
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
|
AHB_FREQ = 600000000 // 600 MHz
|
||||||
CAN_FREQ = 40000000 // 40 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(),
|
// | ARM SysTick is used for most Ardiuno timing functions, delay(), millis(),
|
||||||
// | micros(). SysTick can run from either the ARM core clock, or from an
|
// | micros(). SysTick can run from either the ARM core clock, or from an
|
||||||
|
|
|
@ -11,15 +11,14 @@ import (
|
||||||
|
|
||||||
type timeUnit int64
|
type timeUnit int64
|
||||||
|
|
||||||
const (
|
const ( // HW divides 24 MHz XTALOSC down to 100 kHz
|
||||||
SYST_FREQ = OSC_FREQ // HW divides 24 MHz XTALOSC down to 100 kHz
|
lastCycle = SYSTICK_FREQ/1000 - 1
|
||||||
lastCycle = SYST_FREQ/1000 - 1
|
microsPerCycle = 1000000 / SYSTICK_FREQ
|
||||||
microsPerCycle = 1000000 / SYST_FREQ
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PIT_FREQ = OSC_FREQ // HW divides 24 MHz XTALOSC down to 100 kHz
|
PIT_FREQ = PERCLK_FREQ
|
||||||
pitMicrosPerCycle = 1000000 / PIT_FREQ
|
pitCyclesPerMicro = PIT_FREQ / 1000000
|
||||||
pitSleepTimer = 0 // x4 32-bit PIT timers [0..3]
|
pitSleepTimer = 0 // x4 32-bit PIT timers [0..3]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -88,7 +87,7 @@ func sleepTicks(duration timeUnit) {
|
||||||
curr := ticks()
|
curr := ticks()
|
||||||
last := curr + duration
|
last := curr + duration
|
||||||
for curr < last {
|
for curr < last {
|
||||||
cycles := timeUnit((last - curr) * pitMicrosPerCycle)
|
cycles := timeUnit((last - curr) / pitCyclesPerMicro)
|
||||||
if cycles > 0xFFFFFFFF {
|
if cycles > 0xFFFFFFFF {
|
||||||
cycles = 0xFFFFFFFF
|
cycles = 0xFFFFFFFF
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче