rusEFI
The most advanced open source ECU
|
This logic automatically detects the speed of the oscillator or crystal connected to HSE.
It works by first using the reasonably-precise HSI oscillator (16MHz) to measure LSI (nominally 32khz, but wide tolerance). Then, it switches the system clock source to HSE, and repeats the same measurement. The inaccurate LSI will not drift significantly in the short period of time between these two measurements, so use it as a transfer standard to compare the speed of HSI and HSE. The ratio between the measured speed of LSI when running on HSE vs. HSI will give the ratio of speeds of HSE and HSI themselves. Since we know the value of HSI (16mhz), we can compute the speed of HSE.
Lastly, the PLL is reconfigured to use the correct input divider such that the input frequency is 1MHz (PLLM is set to N for an N-MHz HSE crystal).
Definition in file osc_detector.cpp.
Functions | |
static uint32_t | getOneCapture () |
static uint32_t | getTimerCounts (size_t count) |
static void | enableTimer () |
static void | disableTimer () |
static void | reprogramPll (uint8_t roundedHseMhz) |
void | __late_init () |
Variables | |
float | hseFrequencyMhz |
uint8_t | autoDetectedRoundedMhz |
static const float | rtcpreDivider = 63 |
void __late_init | ( | void | ) |
|
static |
Definition at line 68 of file osc_detector.cpp.
Referenced by __late_init().
|
static |
Definition at line 64 of file osc_detector.cpp.
Referenced by __late_init().
|
static |
Definition at line 32 of file osc_detector.cpp.
Referenced by getTimerCounts().
|
static |
Definition at line 40 of file osc_detector.cpp.
Referenced by __late_init().
|
static |
Definition at line 72 of file osc_detector.cpp.
Referenced by __late_init().
uint8_t autoDetectedRoundedMhz |
Definition at line 24 of file osc_detector.cpp.
Referenced by __late_init(), and sayHello().
float hseFrequencyMhz |
Definition at line 23 of file osc_detector.cpp.
Referenced by __late_init(), and sayHello().
|
static |
Definition at line 62 of file osc_detector.cpp.
Referenced by __late_init().