Always use oversampling with LMS_SetSampleRate()
now oversample param:
value 1 has same effect as 2
value 0 never bypasses decimator/interpolator
@@ -370,19 +370,13 @@ int LMS7_Device::SetRate(double f_Hz, int oversample)
}
if (oversample == 0)
- oversample = LMS_CGEN_MAX/(8*f_Hz);
+ oversample = LMS_CGEN_MAX/(4*f_Hz);
- if (oversample > 1)
- {
for (decim = 0; decim < 4; decim++)
- {
if ( (1<<decim) >= (oversample+1)/2)
break;
- }
- }
- else decim = 7;
- int ratio = oversample <= 2 ? 2 : (2<<decim);
+ int ratio = 2<<decim;
float_type cgen = f_Hz*4*ratio;
if (cgen > LMS_CGEN_MAX)
{
@@ -404,11 +398,8 @@ int LMS7_Device::SetRate(double f_Hz, int oversample)
float_type fpgaTxPLL = lms->GetReferenceClk_TSP(lime::LMS7002M::Tx);
float_type fpgaRxPLL = lms->GetReferenceClk_TSP(lime::LMS7002M::Rx);
- if (decim != 7)
- {
fpgaTxPLL /= pow(2.0, decim);
fpgaRxPLL /= pow(2.0, decim);
- }
if (this->connection->UpdateExternalDataRate(i, fpgaTxPLL / 2, fpgaRxPLL / 2) != 0)
return -1;
}
@@ -479,21 +470,13 @@ int LMS7_Device::SetRate(bool tx, double f_Hz, unsigned oversample)
}
if (oversample == 0)
- oversample = tx ? LMS_CGEN_MAX/(2*f_Hz) : LMS_CGEN_MAX/(8*f_Hz);
+ oversample = tx ? LMS_CGEN_MAX/f_Hz : LMS_CGEN_MAX/(4*f_Hz);
- if (oversample > 1)
- {
for (tmp = 0; tmp < 4; tmp++)
- {
if ( size_t(1<<tmp) >= (oversample+1)/2)
- {
break;
- }
- }
- }
- else tmp = 7;
- int ratio = oversample <= 2 ? 2 : (2<<tmp);
+ int ratio = 2<<tmp;
if (tx)
{
@@ -635,12 +618,12 @@ int LMS7_Device::SetRate(bool tx, double f_Hz, unsigned oversample)
if (tx)
{
- ratio = oversample <= 2 ? 2 : (2<<interpolation);
+ ratio = 2<<interpolation;
cgen = f_Hz*ratio;
}
else
{
- ratio = oversample <= 2 ? 2 : (2<<decimation);
+ ratio = 2<<decimation;
cgen = f_Hz * ratio * 4;
}
@@ -682,12 +665,8 @@ int LMS7_Device::SetRate(bool tx, double f_Hz, unsigned oversample)
float_type fpgaTxPLL = lms->GetReferenceClk_TSP(lime::LMS7002M::Tx);
float_type fpgaRxPLL = lms->GetReferenceClk_TSP(lime::LMS7002M::Rx);
- if (interpolation != 7) {
fpgaTxPLL /= pow(2.0, interpolation);
- }
- if (decimation != 7) {
fpgaRxPLL /= pow(2.0, decimation);
- }
if (this->connection->UpdateExternalDataRate(i, fpgaTxPLL / 2, fpgaRxPLL / 2) != 0)
return -1;
}
