diff --git a/main.c b/main.c index a829820..080e2c0 100644 --- a/main.c +++ b/main.c @@ -174,7 +174,7 @@ static THD_FUNCTION(Thread1, arg) b.mode = setting.mode; b.checksum = 0; uint8_t *c = (uint8_t *)&b; - int ci = USED_BACKUP_SIZE*4; + int ci = sizeof(backup_t)-1; // Exclude checksum uint8_t checksum = 0x55; while (ci--) { checksum ^= *c++; @@ -3057,7 +3057,7 @@ int main(void) while (i--) *t++ = *f++; uint8_t *c = (uint8_t *)&b; - int ci = USED_BACKUP_SIZE*3; + int ci = sizeof(backup_t)-1; uint8_t checksum = 0x55; while (ci--) { checksum ^= *c++; @@ -3088,20 +3088,20 @@ int main(void) set_sweep_frequency(ST_SPAN, (b.frequency1 - b.frequency0)); ui_mode_menu(); } - if (b.attenuation == 0) + if (b.attenuation == 0) { set_auto_attenuation(); - else { + } else { set_attenuation((b.attenuation - 1)/2.0); } - if (b.reflevel == 0) + if (b.reflevel == 0) { set_auto_reflevel(true); - else { + } else { set_auto_reflevel(false); user_set_reflevel((float)(b.reflevel-140)); } - if (b.RBW == 0) + if (b.RBW == 0) { setting.rbw_x10 = 0; - else { + } else { set_RBW(force_rbw(b.RBW-1)); } } diff --git a/nanovna.h b/nanovna.h index 9bec275..5ab3b90 100644 --- a/nanovna.h +++ b/nanovna.h @@ -1831,7 +1831,8 @@ extern int signal_path; extern int test_path; extern int force_signal_path; - +extern uint16_t R; +extern uint8_t rfPower; extern void ADF4351_mux(int R); extern void ADF4351_force_refresh(void); extern void ADF4351_CP(int p); diff --git a/sa_core.c b/sa_core.c index 22e1681..b82cb86 100644 --- a/sa_core.c +++ b/sa_core.c @@ -4071,7 +4071,7 @@ again: // Spur redu #ifdef __ULTRA__ if (S_IS_AUTO(setting.below_IF)) { - if ((freq_t)lf > MAX_ABOVE_IF_FREQ && lf <= ULTRA_MAX_FREQ ) + if ((freq_t)lf > MAX_ABOVE_IF_FREQ && lf <= ULTRA_MAX_FREQ && !LO_harmonic) setting.below_IF = S_AUTO_ON; // Only way to reach this range. Use below IF in harmonic mode else setting.below_IF = S_AUTO_OFF; // default is above IF, Use below IF in harmonic mode @@ -4337,11 +4337,12 @@ again: // Spur redu } } else if (lf < 25000000 && max2871) { ADF4351_R_counter(-1); + ADF4351_modulo(200); } else if (lf > 8000000 && lf < 3000000000 && MODE_INPUT(setting.mode)) { if (max2871) if (local_modulo == 0) { if (max2871) - ADF4351_modulo(4000); + ADF4351_modulo(100); else ADF4351_modulo(4000); } @@ -4384,8 +4385,11 @@ again: // Spur redu ADF4351_R_counter(3); // To avoid PLL Loop shoulders } else ADF4351_R_counter(1); - } else + } + else if (max2871) ADF4351_R_counter(1); + else + ADF4351_R_counter(2); } else { // Input above 800 MHz if (local_modulo == 0) { @@ -4403,10 +4407,13 @@ again: // Spur redu ADF4351_R_counter(3); } else #endif + if (max2871) ADF4351_R_counter(1); // Used to be 1 + else + ADF4351_R_counter(2); // Used to be 1 } } else { - ADF4351_R_counter(setting.R); + ADF4351_R_counter(setting.R%1000); } } #endif // __ADF4351__ @@ -4610,14 +4617,15 @@ again: // Spur redu } char shifted = ( LO_spur_shifted ? '>' : ' '); if (SDU1.config->usbp->state == USB_ACTIVE) - shell_printf ("%d:%c%c%c%cLO=%11.6Lq:%11.6Lq\tIF=%11.6Lq:%11.6Lq\tOF=%11.6d\tF=%11.6Lq:%11.6Lq\tD=%.2f:%.2f %c%c%c %d\r\n", + shell_printf ("%d:%c%c%c%cLO=%11.6Lq:%11.6Lq\tIF=%11.6Lq:%11.6Lq\tOF=%11.6d\tF=%11.6Lq:%11.6Lq\tD=%.2f:%.2f %c%c%c %d R=%d mod=%d, d=%d\r\n", i, spur, shifted,(LO_mirrored ? 'm' : ' '), (LO_harmonic ? 'h':' ' ), old_freq[ADF4351_LO],real_old_freq[ADF4351_LO], old_freq[SI4463_RX], real_old_freq[SI4463_RX], (int32_t)real_offset, f_low, f_high , f_error_low, f_error_high, (ADF4351_frequency_changed? 'A' : ' '), (SI4463_frequency_changed? 'S' : ' '), (SI4463_offset_changed? 'O' : ' '), - correct_RSSI_freq + correct_RSSI_freq, + R, ADF4351_get_modulo(),rfPower ); osalThreadSleepMilliseconds(100); } diff --git a/si4468.c b/si4468.c index 0a7692d..13a95a0 100644 --- a/si4468.c +++ b/si4468.c @@ -290,7 +290,7 @@ uint16_t R = 1; int old_R = 0; uint16_t N = 1; uint16_t frac = 0; -uint16_t modulus = 32; +uint16_t modulus = 200; uint16_t out_div = 0; uint16_t mux = 0; uint16_t csr = 1; // cycle slip reduction, if enabled cp must be lowest value @@ -310,7 +310,7 @@ bool pdwn = false; uint16_t powerDown = 0; -static const uint8_t auxPower = 0b00; +static const uint8_t auxPower = 0b11; // band select divider. 1 to 255. volatile uint16_t bsDivider = 100; // For set internal logic clock (24M / 192 = 125k) max 125k @@ -349,7 +349,7 @@ static enum { LD_LOW_NOISE = 0b00, LD_LOW_SPUR1 = 0b10, LD_LOW_SPUR2 = 0b11 -} noiseMode = LD_LOW_NOISE; +} noiseMode = LD_LOW_SPUR1; /* static const enum { @@ -617,7 +617,7 @@ uint16_t ADF4351_get_modulo(void) void ADF4351_spur_mode(int S) { - noiseMode = S; +// noiseMode = S; } void ADF4351_R_counter(int new_R)