LMS7002M: improve automatic clock selection
fix clocks selection when switching from int/dec bypass to int/dec > 2
do not change clocks when loopbacks are configured
@@ -2444,9 +2444,6 @@ int LMS7002M::SetInterfaceFrequency(float_type cgen_freq_Hz, const uint8_t inter
Modify_SPI_Reg_bits(LMS7param(RXTSPCLKA_DIV), 0);
Modify_SPI_Reg_bits(LMS7param(RXDIVEN), false);
Modify_SPI_Reg_bits(LMS7param(MCLK2SRC), (mclk2src & 1) | 0x2);
- bool mimoBypass = (decimation == 7) && (siso == 0);
- Modify_SPI_Reg_bits(LMS7param(RXRDCLK_MUX),mimoBypass ? 3 : 1);
- Modify_SPI_Reg_bits(LMS7param(RXWRCLK_MUX),mimoBypass ? 1 : 2);
}
else
{
@@ -2458,6 +2455,14 @@ int LMS7002M::SetInterfaceFrequency(float_type cgen_freq_Hz, const uint8_t inter
Modify_SPI_Reg_bits(LMS7param(RXDIVEN), true);
Modify_SPI_Reg_bits(LMS7param(MCLK2SRC), mclk2src & 1);
}
+
+ if (Get_SPI_Reg_bits(LMS7param(RX_MUX)) == 0)
+ {
+ bool mimoBypass = (decimation == 7) && (siso == 0);
+ Modify_SPI_Reg_bits(LMS7param(RXRDCLK_MUX),mimoBypass ? 3 : 1);
+ Modify_SPI_Reg_bits(LMS7param(RXWRCLK_MUX),mimoBypass ? 1 : 2);
+ }
+
siso = Get_SPI_Reg_bits(LMS7_LML1_SISODDR);
int mclk1src = Get_SPI_Reg_bits(LMS7param(MCLK1SRC));
if (interpolation == 7 || (interpolation == 0 && siso == 0)) //bypass
@@ -2465,9 +2470,6 @@ int LMS7002M::SetInterfaceFrequency(float_type cgen_freq_Hz, const uint8_t inter
Modify_SPI_Reg_bits(LMS7param(TXTSPCLKA_DIV), 0);
Modify_SPI_Reg_bits(LMS7param(TXDIVEN), false);
Modify_SPI_Reg_bits(LMS7param(MCLK1SRC), (mclk1src & 1) | 0x2);
- bool mimoBypass = (interpolation == 7) && (siso == 0);
- Modify_SPI_Reg_bits(LMS7param(TXRDCLK_MUX),mimoBypass ? 0 : 2);
- Modify_SPI_Reg_bits(LMS7param(TXWRCLK_MUX), 0);
}
else
{
@@ -2480,6 +2482,13 @@ int LMS7002M::SetInterfaceFrequency(float_type cgen_freq_Hz, const uint8_t inter
Modify_SPI_Reg_bits(LMS7param(MCLK1SRC), mclk1src & 1);
}
+ if (Get_SPI_Reg_bits(LMS7param(TX_MUX)) == 0)
+ {
+ bool mimoBypass = (interpolation == 7) && (siso == 0);
+ Modify_SPI_Reg_bits(LMS7param(TXRDCLK_MUX),mimoBypass ? 0 : 2);
+ Modify_SPI_Reg_bits(LMS7param(TXWRCLK_MUX), 0);
+ }
+
return status;
}
