Add frequency error
This commit is contained in:
parent
754c341387
commit
3969c35268
2 changed files with 13 additions and 1 deletions
13
src/gpio.cpp
13
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 < 300e6 ) continue; // widest accepted frequency range
|
if( Frequency*divider < 600e6 ) 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));
|
||||||
|
@ -258,6 +258,17 @@ double clkgpio::GetFrequencyResolution()
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double clkgpio::GetRealFrequency(double Frequency)
|
||||||
|
{
|
||||||
|
double FloatMult=((double)(CentralFrequency+Frequency)*PllFixDivider)/(double)(XOSC_FREQUENCY);
|
||||||
|
uint32_t freqctl = FloatMult*((double)(1<<20)) ;
|
||||||
|
int IntMultiply= freqctl>>20; // Need to be calculated to have a center frequency
|
||||||
|
freqctl&=0xFFFFF; // Fractionnal is 20bits
|
||||||
|
uint32_t FracMultiply=freqctl&0xFFFFF;
|
||||||
|
double RealFrequency=((double)IntMultiply+(FracMultiply/(double)(1<<20)))*(double)(XOSC_FREQUENCY)/PllFixDivider-(CentralFrequency+Frequency);
|
||||||
|
return RealFrequency;
|
||||||
|
}
|
||||||
|
|
||||||
int clkgpio::SetCenterFrequency(uint64_t Frequency,int Bandwidth)
|
int clkgpio::SetCenterFrequency(uint64_t Frequency,int Bandwidth)
|
||||||
{
|
{
|
||||||
CentralFrequency=Frequency;
|
CentralFrequency=Frequency;
|
||||||
|
|
|
@ -162,6 +162,7 @@ class clkgpio:public gpio
|
||||||
void SetAdvancedPllMode(bool Advanced);
|
void SetAdvancedPllMode(bool Advanced);
|
||||||
int SetCenterFrequency(uint64_t Frequency,int Bandwidth);
|
int SetCenterFrequency(uint64_t Frequency,int Bandwidth);
|
||||||
double GetFrequencyResolution();
|
double GetFrequencyResolution();
|
||||||
|
double GetRealFrequency(double Frequency);
|
||||||
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