Add frequency resolution computing
This commit is contained in:
parent
2925373382
commit
754c341387
2 changed files with 18 additions and 1 deletions
18
src/gpio.cpp
18
src/gpio.cpp
|
@ -194,7 +194,7 @@ int clkgpio::ComputeBestLO(uint64_t Frequency,int Bandwidth)
|
||||||
best_divider=0;
|
best_divider=0;
|
||||||
for( divider=1;divider<4096;divider++)
|
for( divider=1;divider<4096;divider++)
|
||||||
{
|
{
|
||||||
if( Frequency*divider < 600e6 ) continue; // widest accepted frequency range
|
if( Frequency*divider < 300e6 ) continue; // widest accepted frequency range
|
||||||
if( Frequency*divider > 1500e6 ) break;
|
if( Frequency*divider > 1500e6 ) break;
|
||||||
|
|
||||||
max_int_multiplier=((int)((double)(Frequency+Bandwidth)*divider*xtal_freq_recip));
|
max_int_multiplier=((int)((double)(Frequency+Bandwidth)*divider*xtal_freq_recip));
|
||||||
|
@ -242,6 +242,22 @@ int clkgpio::ComputeBestLO(uint64_t Frequency,int Bandwidth)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double clkgpio::GetFrequencyResolution()
|
||||||
|
{
|
||||||
|
double res=0;
|
||||||
|
if(ModulateFromMasterPLL)
|
||||||
|
{
|
||||||
|
res=XOSC_FREQUENCY/(double)(1<<20)/PllFixDivider;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double Freqresult=(double)Pllfrequency/(double)(CentralFrequency);
|
||||||
|
uint32_t FreqDivider=(uint32_t)Freqresult;
|
||||||
|
res=(Pllfrequency/(double)(FreqDivider+1)-Pllfrequency/(double)(FreqDivider))/4096.0;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
int clkgpio::SetCenterFrequency(uint64_t Frequency,int Bandwidth)
|
int clkgpio::SetCenterFrequency(uint64_t Frequency,int Bandwidth)
|
||||||
{
|
{
|
||||||
CentralFrequency=Frequency;
|
CentralFrequency=Frequency;
|
||||||
|
|
|
@ -161,6 +161,7 @@ class clkgpio:public gpio
|
||||||
void SetPhase(bool inversed);
|
void SetPhase(bool inversed);
|
||||||
void SetAdvancedPllMode(bool Advanced);
|
void SetAdvancedPllMode(bool Advanced);
|
||||||
int SetCenterFrequency(uint64_t Frequency,int Bandwidth);
|
int SetCenterFrequency(uint64_t Frequency,int Bandwidth);
|
||||||
|
double GetFrequencyResolution();
|
||||||
int ComputeBestLO(uint64_t Frequency,int Bandwidth);
|
int ComputeBestLO(uint64_t Frequency,int Bandwidth);
|
||||||
int SetMasterMultFrac(uint32_t Mult,uint32_t Frac);
|
int SetMasterMultFrac(uint32_t Mult,uint32_t Frac);
|
||||||
uint32_t GetMasterFrac(double Frequency);
|
uint32_t GetMasterFrac(double Frequency);
|
||||||
|
|
Loading…
Reference in a new issue