Removed freq grid and corrected spur avoidance bug

pull/8/head
erikkaashoek 5 years ago
parent 3e428150de
commit d2964514b3

@ -1333,11 +1333,13 @@ search_maximum(int m, int center, int span)
//static int spur_old_stepdelay = 0; //static int spur_old_stepdelay = 0;
static const unsigned int spur_IF = 433800000; // The IF frequency for which the spur table is value static const unsigned int spur_IF = 433800000; // The IF frequency for which the spur table is value
static const unsigned int spur_alternate_IF = 433900000; // if the frequency is found in the spur table use this IF frequency static const unsigned int spur_alternate_IF = 434000000; // if the frequency is found in the spur table use this IF frequency
static const int spur_table[] = // Frequencies to avoid static const int spur_table[] = // Frequencies to avoid
{ {
// 580000, // 433.8 MHz table // 580000, // 433.8 MHz table
// 880000, //?
960000, 960000,
// 1487000, //?
1600000, 1600000,
// 1837000, // Real signal // 1837000, // Real signal
// 2755000, // Real signal // 2755000, // Real signal
@ -1404,8 +1406,8 @@ int binary_search(int f)
{ {
int L = 0; int L = 0;
int R = (sizeof spur_table)/sizeof(int) - 1; int R = (sizeof spur_table)/sizeof(int) - 1;
int fmin = f - actual_rbw_x10 * 100; int fmin = f - actual_rbw_x10 * (100 / 2);
int fplus = f + actual_rbw_x10 * 100; int fplus = f + actual_rbw_x10 * (100 / 2);
while (L <= R) { while (L <= R) {
int m = (L + R) / 2; int m = (L + R) / 2;
if (spur_table[m] < fmin) if (spur_table[m] < fmin)
@ -1584,6 +1586,10 @@ modulation_again:
// -------------------------------- Acquisition loop for one requested frequency covering spur avoidance and vbwsteps ------------------------ // -------------------------------- Acquisition loop for one requested frequency covering spur avoidance and vbwsteps ------------------------
pureRSSI_t RSSI = float_TO_PURE_RSSI(-150); pureRSSI_t RSSI = float_TO_PURE_RSSI(-150);
#define __DEBUG_SPUR__
#ifdef __DEBUG_SPUR__ // For debugging the spur avoidance control
stored_t[i] = -90.0; // Display when to do spur shift in the stored trace
#endif
int t = 0; int t = 0;
do { do {
uint32_t lf = f; uint32_t lf = f;
@ -1609,7 +1615,7 @@ modulation_again:
local_IF = 0; local_IF = 0;
else { else {
if (setting.auto_IF) if (setting.auto_IF)
local_IF = setting.spur_removal ? 433900000 : 433800000; local_IF = setting.spur_removal ? 433900000 : spur_IF;
else else
local_IF = setting.frequency_IF; local_IF = setting.frequency_IF;
} }
@ -1618,8 +1624,11 @@ modulation_again:
set_freq (SI4432_RX , local_IF + lf - reffer_freq[setting.refer]); // Offset so fundamental of reffer is visible set_freq (SI4432_RX , local_IF + lf - reffer_freq[setting.refer]); // Offset so fundamental of reffer is visible
#endif #endif
} else if (MODE_LOW(setting.mode)) { } else if (MODE_LOW(setting.mode)) {
if (setting.mode == M_LOW && !in_selftest && avoid_spur(f)) { // check is alternate IF is needed to avoid spur. if (setting.mode == M_LOW && !in_selftest && avoid_spur(lf)) { // check if alternate IF is needed to avoid spur.
local_IF = spur_alternate_IF; local_IF = spur_alternate_IF;
#ifdef __DEBUG_SPUR__ // For debugging the spur avoidance control
stored_t[i] = -60.0; // Display when to do spur shift in the stored trace
#endif
#ifdef __SPUR__ #ifdef __SPUR__
} else if (setting.mode== M_LOW && setting.spur_removal){ // If in low input mode and spur reduction is on } else if (setting.mode== M_LOW && setting.spur_removal){ // If in low input mode and spur reduction is on
if (S_IS_AUTO(setting.below_IF) && lf < 150000000) // if below 150MHz and auto_below_IF if (S_IS_AUTO(setting.below_IF) && lf < 150000000) // if below 150MHz and auto_below_IF
@ -1829,6 +1838,7 @@ static bool sweep(bool break_on_operation)
// if (setting.mode== -1) // if (setting.mode== -1)
// return; // return;
// START_PROFILE; // START_PROFILE;
START_PROFILE;
palClearPad(GPIOB, GPIOB_LED); palClearPad(GPIOB, GPIOB_LED);
@ -1922,9 +1932,6 @@ sweep_again: // stay in sweep loop when output mo
// #define __DEBUG_AGC__ // #define __DEBUG_AGC__
#ifdef __DEBUG_AGC__ // For debugging the AGC control #ifdef __DEBUG_AGC__ // For debugging the AGC control
stored_t[i] = (SI4432_Read_Byte(0x69) & 0x01f) * 3.0 - 90.0; // Display the AGC value in the stored trace stored_t[i] = (SI4432_Read_Byte(0x69) & 0x01f) * 3.0 - 90.0; // Display the AGC value in the stored trace
#endif
#ifdef __DEBUG_SPUR__ // For debugging the spur avoidance control
stored_t[i] = (avoid_spur(frequencies[i]) ? -60.0 : - 90.0); // Display when to do spur shift in the stored trace
#endif #endif
if (scandirty || setting.average == AV_OFF) { // Level calculations if (scandirty || setting.average == AV_OFF) { // Level calculations
actual_t[i] = RSSI; actual_t[i] = RSSI;
@ -2338,6 +2345,7 @@ sweep_again: // stay in sweep loop when output mo
ili9341_fill(OFFSETX, HEIGHT_NOSCROLL+1, WIDTH, 1, 0); ili9341_fill(OFFSETX, HEIGHT_NOSCROLL+1, WIDTH, 1, 0);
palSetPad(GPIOB, GPIOB_LED); palSetPad(GPIOB, GPIOB_LED);
STOP_PROFILE;
return true; return true;
} }

@ -349,7 +349,7 @@ void SI4432_Set_Frequency ( uint32_t Freq ) {
// int mode = SI4432_Read_Byte(0x02) & 0x03; // Disabled as unreliable // int mode = SI4432_Read_Byte(0x02) & 0x03; // Disabled as unreliable
// SI4432_Write_Byte(0x07, 0x02); // Switch to tune mode // SI4432_Write_Byte(0x07, 0x02); // Switch to tune mode
Freq = (Freq / 1000 ) * 1000; // force freq to 1000 grid // Freq = (Freq / 1000 ) * 1000; // force freq to 1000 grid
uint8_t hbsel; uint8_t hbsel;
if (0) shell_printf("%d: Freq %q\r\n", SI4432_Sel, Freq); if (0) shell_printf("%d: Freq %q\r\n", SI4432_Sel, Freq);

Loading…
Cancel
Save

Powered by TurnKey Linux.