Skip to content

Commit

Permalink
#1715 Resolves issue of using both legacy and new V4 RTL2832 dongles …
Browse files Browse the repository at this point in the history
…at same time causes errant tuning behavior on the first tuner that gets initialized. Removed static qualifier from VCO reference value so that each tuner is allowed to initialize correctly.
  • Loading branch information
Dennis Sheirer committed Nov 10, 2023
1 parent 88879c9 commit 279aca7
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public abstract class R8xEmbeddedTuner extends EmbeddedTuner
private static final byte VERSION = (byte) 49;
protected static final int IF_FREQUENCY = 3570000;
private static final Logger mLog = LoggerFactory.getLogger(R8xEmbeddedTuner.class);
private static int mVcoPowerRef = 1;
private int mVcoPowerRef = 1;

/**
* Shadow register is used to keep a cached (in-memory) copy of all registers, so that we don't have to read a
Expand Down Expand Up @@ -232,10 +232,11 @@ protected void setPLL(long frequency, boolean controlI2C) throws UsbException
FrequencyDivider divider = FrequencyDivider.fromFrequency(frequency);
int statusRegister4 = getStatusRegister(4, controlI2C);
int vco_fine_tune = (statusRegister4 & 0x30) >> 4;
int div_num = divider.getDividerNumber(vco_fine_tune);
int div_num = divider.getDividerNumber(vco_fine_tune, mVcoPowerRef);
writeRegister(Register.DIVIDER, (byte) (div_num << 5), controlI2C);
/* Get the integral number for this divider and frequency */
Integral integral = divider.getIntegral(frequency);
System.out.println("Using divider [" + divider + "] integral [" + integral + "] for [" + frequency + "]");
writeRegister(Register.PLL, integral.getRegisterValue(), controlI2C);
/* Calculate the sigma-delta modulator fractional setting. If it's non-zero, power up the sdm and apply the
fractional setting, otherwise turn it off */
Expand Down Expand Up @@ -984,17 +985,17 @@ public enum FrequencyDivider
mIntegralValue = integralValue;
}

public int getDividerNumber(int vcoFineTune)
public int getDividerNumber(int vcoFineTune, int vcoPowerRef)
{
if(vcoFineTune == mVcoPowerRef)
if(vcoFineTune == vcoPowerRef)
{
return mDividerNumber;
}
else if(vcoFineTune < mVcoPowerRef)
else if(vcoFineTune < vcoPowerRef)
{
return mDividerNumber - 1;
}
else if(vcoFineTune > mVcoPowerRef)
else if(vcoFineTune > vcoPowerRef)
{
return mDividerNumber + 1;
}
Expand Down

0 comments on commit 279aca7

Please sign in to comment.