On MD3x0 baseband, fixed PLL going nuts for some frequencies (e.g. 430.0MHz) and causing the radio transmitting on a shifted band.

replace/b3c31fb73da21edeb9ede3f001b04d15415e74c0
Silvano Seva 2020-12-19 10:12:05 +01:00
rodzic d74bece14e
commit f0862abac1
1 zmienionych plików z 16 dodań i 0 usunięć

Wyświetl plik

@ -88,6 +88,22 @@ void pll_setFrequency(float freq, uint8_t clkDiv)
float Ndiv = floor(K) - 32.0;
float Ndnd = round(262144*(K - Ndiv - 32.0));
/*
* With PLL in fractional mode, dividend range is [-131017 +131071]. If our
* computation gives a wrong result, we decrement the reference clock divider
* and redo the computations.
*
* TODO: better investigate on how to put PLL in unsigned dividend mode.
*/
if(((uint32_t) Ndnd) >= 131070)
{
clkDiv -= 1;
K = freq/(REF_CLK/((float) clkDiv));
Ndiv = floor(K) - 32.0;
Ndnd = round(262144*(K - Ndiv - 32.0));
}
uint32_t dnd = ((uint32_t) Ndnd);
uint16_t dndMsb = dnd >> 8;
uint16_t dndLsb = dnd & 0x00FF;