mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-24 23:09:26 -05:00
Simplify PLL math when correcting for PPM.
This commit is contained in:
parent
98773cb62a
commit
4974774f82
@ -370,9 +370,10 @@ void ClockManager::set_sampling_frequency(const uint32_t frequency) {
|
||||
|
||||
void ClockManager::set_reference_ppb(const int32_t ppb) {
|
||||
constexpr uint32_t pll_multiplier = si5351_pll_xtal_25m.a;
|
||||
constexpr uint32_t denominator = 1000000 / pll_multiplier;
|
||||
const uint32_t new_a = (ppb >= 0) ? pll_multiplier : (pll_multiplier - 1);
|
||||
const uint32_t new_b = (ppb >= 0) ? (ppb * pll_multiplier / 1000) : (1000000 + (ppb * pll_multiplier / 1000));
|
||||
const uint32_t new_c = (ppb == 0) ? 1 : 1000000;
|
||||
const uint32_t new_b = (ppb >= 0) ? (ppb / 1000) : (denominator + (ppb / 1000));
|
||||
const uint32_t new_c = (ppb == 0) ? 1 : denominator;
|
||||
|
||||
const si5351::PLL pll {
|
||||
.f_in = si5351_inputs.f_xtal,
|
||||
|
Loading…
Reference in New Issue
Block a user