LPF RX calibration fails with MCU error 12 (Rx R_CTL_LPF range limit reached) when calibration is started second time.
Issue can be reproduced with the test program below:
// Test of LMS_SetLPFBW
#include <stdio.h>
#include “lime/LimeSuite.h”
lms_device_t* device = NULL;
lms_stream_t streamId;
int main(void)
{
int n;
lms_info_str_t list[8];
float_type freq;
float_type sample_rate;
size_t oversample;
unsigned int gain;
freq = 796000000;
sample_rate = 1.92e6;
oversample = 4;
gain = 70; // 70, 71, 72 dB causes LPF failure at second time
// MCU error 12 (Rx R_CTL_LPF range limit reached)
// 69, 73 works
if ((n = LMS_GetDeviceList(list)) < 0)
return -1;
if (n < 1)
return -1;
if (LMS_Open(&device, list[0], NULL))
return -1;
if (LMS_Init(device) != 0)
return -1;
if (LMS_EnableChannel(device, LMS_CH_RX, 0, true) != 0)
return -1;
if (LMS_SetAntenna(device, LMS_CH_RX, 0, LMS_PATH_LNAW) != 0)
return -1;
if (LMS_SetGaindB(device, LMS_CH_RX, 0, gain) != 0)
return -1;
if (LMS_SetLOFrequency(device, LMS_CH_RX, 0, freq) != 0)
{
printf("Tuning to %f Hz failed!\n", freq);
return -1;
}
if (LMS_SetSampleRate(device, sample_rate, oversample) != 0)
return -1;
if (LMS_SetLPFBW(device, LMS_CH_RX, 0, sample_rate) != 0)
return -1;
if (LMS_Calibrate(device, LMS_CH_RX, 0, 2.5e6, 0) != 0)
return -1;
#if 0
//Initialize stream
streamId.channel = 0; //channel number
streamId.fifoSize = 1024 * 1024;
streamId.throughputVsLatency = 0.3;
streamId.isTx = false; //RX channel
streamId.dataFmt = lms_stream_t::LMS_FMT_F32;
if (LMS_SetupStream(device, &streamId) != 0)
return -1;
//Start streaming
LMS_StartStream(&streamId);
LMS_StopStream(&streamId);
LMS_DestroyStream(device, &streamId);
#endif
if (LMS_SetSampleRate(device, sample_rate, oversample) != 0)
return -1;
// fails if gain = 70 dB
if (LMS_SetLPFBW(device, LMS_CH_RX, 0, sample_rate) != 0)
{
printf("LPF setting failed!\n");
return -1;
}
if (LMS_Calibrate(device, LMS_CH_RX, 0, 2.5e6, 0) != 0)
return -1;
#if 0
if (LMS_SetupStream(device, &streamId) != 0)
return -1;
//Start streaming
LMS_StartStream(&streamId);
LMS_StopStream(&streamId);
LMS_DestroyStream(device, &streamId);
#endif
LMS_Close(device);
return 0;
}