From 61b4e0ba96607aa71226677ff55c6d9247163fba Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 9 Feb 2021 12:59:31 +0100 Subject: [PATCH] Improved low spur reduction --- chprintf.c | 4 ++-- sa_core.c | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/chprintf.c b/chprintf.c index a854f05..90736ba 100644 --- a/chprintf.c +++ b/chprintf.c @@ -419,8 +419,8 @@ unsigned_common: if (state & IS_LONG) value.x = va_arg(ap, uint64_t); else - value.u = va_arg(ap, uint32_t); - p = long_to_string_with_divisor(p, value.u, c, 0); + value.x = va_arg(ap, uint32_t); + p = long_to_string_with_divisor(p, value.x, c, 0); break; default: *p++ = c; diff --git a/sa_core.c b/sa_core.c index 5c4a744..d928ce0 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1102,8 +1102,8 @@ void calculate_step_delay(void) #endif #endif #ifdef __SI4463__ - if (actual_rbw_x10 >= 6000) { SI4432_step_delay = 400; SI4432_offset_delay = 100; spur_gate = 50; } - else if (actual_rbw_x10 >= 3000) { SI4432_step_delay = 400; SI4432_offset_delay = 100; spur_gate = 50; } + if (actual_rbw_x10 >= 6000) { SI4432_step_delay = 400; SI4432_offset_delay = 100; spur_gate = 60; } + else if (actual_rbw_x10 >= 3000) { SI4432_step_delay = 400; SI4432_offset_delay = 100; spur_gate = 60; } else if (actual_rbw_x10 >= 1000) { SI4432_step_delay = 400; SI4432_offset_delay = 100; spur_gate = 70; } else if (actual_rbw_x10 >= 300) { SI4432_step_delay = 400; SI4432_offset_delay = 120; spur_gate = 200; } else if (actual_rbw_x10 >= 100) { SI4432_step_delay = 500; SI4432_offset_delay = 180; spur_gate = 300; } @@ -2200,7 +2200,9 @@ modulation_again: } } } else if(!in_selftest && avoid_spur(lf)) { // check if alternate IF is needed to avoid spur. - if (setting.auto_IF) { + if (S_IS_AUTO(setting.below_IF) && lf < local_IF/2 - 1000000) { + setting.below_IF = S_AUTO_ON; + } else if (setting.auto_IF) { local_IF = local_IF + DEFAULT_SPUR_OFFSET; // if (actual_rbw_x10 == 6000 ) // local_IF = local_IF + 50000; @@ -2346,7 +2348,7 @@ modulation_again: } else target_f = local_IF+lf; // otherwise to above IF #endif - if (setting.harmonic && f > ULTRA_MAX_FREQ) { + if (setting.harmonic && lf > ULTRA_MAX_FREQ) { target_f /= setting.harmonic; LO_harmonic = true; } @@ -2360,7 +2362,7 @@ modulation_again: goto correct_min; } correct_plus: - if (setting.harmonic && f > ULTRA_MAX_FREQ) { + if (setting.harmonic && lf > ULTRA_MAX_FREQ) { error_f *= setting.harmonic; } if (error_f > actual_rbw_x10 * 5) //RBW / 4 @@ -2372,7 +2374,7 @@ modulation_again: goto correct_plus; } correct_min: - if (setting.harmonic && f > ULTRA_MAX_FREQ) { + if (setting.harmonic && lf > ULTRA_MAX_FREQ) { error_f *= setting.harmonic; } if ( error_f < - actual_rbw_x10 * 5) //RBW / 4 @@ -2417,10 +2419,10 @@ modulation_again: freq_t f_low, f_high; if (setting.mode == M_LOW || setting.mode == M_GENLOW) { if (real_old_freq[ADF4351_LO] > (real_old_freq[SI4463_RX] + real_offset)) - f_low = (mult*real_old_freq[ADF4351_LO]) - (real_old_freq[SI4463_RX] + real_offset); // f below LO + f_low = (mult*real_old_freq[ADF4351_LO]) - (real_old_freq[SI4463_RX] + real_offset); // lf below LO else f_low = (real_old_freq[SI4463_RX] + real_offset) - (mult*real_old_freq[ADF4351_LO]); - f_high = (mult*real_old_freq[ADF4351_LO]) + (real_old_freq[SI4463_RX] + real_offset); // f above LO + f_high = (mult*real_old_freq[ADF4351_LO]) + (real_old_freq[SI4463_RX] + real_offset); // lf above LO } else f_low = f_high = real_old_freq[SI4463_RX] + real_offset; float f_error_low, f_error_high;