From 84ca6b2525ecc647a86219c05b64737617f3e1dc Mon Sep 17 00:00:00 2001 From: Jason Milldrum Date: Sat, 15 Apr 2017 14:44:40 -0700 Subject: [PATCH] Fix error in VCXO algorithm --- README.md | 6 ++++++ library.properties | 2 +- src/si5351.cpp | 4 ++-- src/si5351.h | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 60c0625..5c04552 100644 --- a/README.md +++ b/README.md @@ -249,6 +249,8 @@ PLLA and PLLB are set to 800 MHz (also defined as _SI5351_PLL_FIXED_ in the libr All CLK outputs are set to 0 Hz and disabled. +Default drive strength is 2 mA on each output. + Constraints ----------- * Two multisynths cannot share a PLL with when both outputs are >= 100 MHz. The library will refuse to set another multisynth to a frequency in that range if another multisynth sharing the same PLL is already within that frequency range. @@ -663,6 +665,10 @@ This library does not currently support the spread spectrum function of the Si53 Changelog --------- +* v2.0.4 + + * Fix error in VCXO algorithm + * v2.0.3 * Fix regression in _set_freq()_ that wiped out proper R div setting, causing errors in setting low frequency outputs diff --git a/library.properties b/library.properties index 9e1fa82..12cfe7f 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Etherkit Si5351 -version=2.0.3 +version=2.0.4 author=Jason Milldrum maintainer=Jason Milldrum sentence=A full-featured library for the Si5351 series of clock generator ICs from Silicon Labs diff --git a/src/si5351.cpp b/src/si5351.cpp index 9347551..c77e87c 100644 --- a/src/si5351.cpp +++ b/src/si5351.cpp @@ -1197,7 +1197,7 @@ void Si5351::set_vcxo(uint64_t pll_freq, uint8_t ppm) delete params; // Write the VCXO parameters - vcxo_param = (vcxo_param * ppm) / RFRAC_DENOM; + vcxo_param = ((vcxo_param * ppm * SI5351_VCXO_MARGIN) / 100ULL) / 1000000ULL; temp = (uint8_t)(vcxo_param & 0xFF); si5351_write(SI5351_VXCO_PARAMETERS_LOW, temp); @@ -1319,7 +1319,7 @@ uint64_t Si5351::pll_calc(uint64_t freq, struct Si5351RegSet *reg, int32_t corre if(vcxo) { - return (uint64_t)(128 * a * SI5351_VCXO_MARGIN + b * SI5351_VCXO_MARGIN); + return (uint64_t)(128 * a * 1000000ULL + b); } else { diff --git a/src/si5351.h b/src/si5351.h index 24abc3b..dbed20e 100644 --- a/src/si5351.h +++ b/src/si5351.h @@ -69,7 +69,7 @@ #define SI5351_MULTISYNTH_P3_MAX ((1<<20)-1) #define SI5351_VCXO_PULL_MIN 30 #define SI5351_VCXO_PULL_MAX 240 -#define SI5351_VCXO_MARGIN 1030000 +#define SI5351_VCXO_MARGIN 103 #define SI5351_DEVICE_STATUS 0 #define SI5351_INTERRUPT_STATUS 1