unsigned char Algorithm_B_RBB (unsigned short *LowFreqAmp)
{
unsigned short ADCOUT;
unsigned char CG_IAMP_TBB, gain_inc;
Set_NCO_Freq (0.1); // Set DAC output to 100kHz (0.1MHz) single tone.
CG_IAMP_TBB = 24; //set nominal CG_IAMP_TBB value
Modify_SPI_Reg_bits (0x0108, 15, 10, CG_IAMP_TBB); //write val to reg
//Modify_SPI_Reg_bits (0x040A, 13, 12, 1); // AGC Mode = 1 (RSSI mode)
ADCOUT = Get_SPI_Reg_bits(0x040B, 15, 0); //RSSI value // Measure the output level at the ADC input
if(ADCOUT < 52428) gain_inc = 1; //is it less then 80% of full scale swing (52428 (80% of 16 bits))
else gain_inc = 0;
while (1)
{
if(gain_inc) CG_IAMP_TBB++;
else CG_IAMP_TBB--;
Modify_SPI_Reg_bits (0x0108, 15, 10, CG_IAMP_TBB); //write val to reg
ADCOUT = Get_SPI_Reg_bits(0x040B, 15, 0); //RSSI value // Measure the output level at the ADC input
if (gain_inc)
{
if(ADCOUT >= 52428) break;
}
else
{
if(ADCOUT <= 52428) break;
}
if( (CG_IAMP_TBB == 0) || (CG_IAMP_TBB == 63)) //gain limit reached
{
return 0;
break;
}
}
*LowFreqAmp = ADCOUT;
return 1;
}
1. If (“CalFreq”) <=10MHz, then CONTROL=C_CTL_LPFL_RBB, else,
2. Set the CONTROL to maximum value. This should bring the output cut-off frequency
to minimum.
3. Apply a single tone frequency at “CalFreq”.
4. Measure the value of the amplitude at the ADC input.
5. If ADC value >= LowFreqAmp, then jump back to line #8.
6. Decrease the CONTROL value by one.
7. Jump back to line #4
8. Save the value of CONTROL.