From 82fc1cbd10e683db4b1225c920892866bd6e23f0 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Sun, 27 Dec 2020 13:44:04 +0100 Subject: [PATCH] Modulo setting has direct effect --- nanovna.h | 1 + sa_core.c | 10 +++++----- si4432.c | 6 ++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/nanovna.h b/nanovna.h index ea9e8fc..a02076c 100644 --- a/nanovna.h +++ b/nanovna.h @@ -1136,6 +1136,7 @@ enum { extern void ADF4351_mux(int R); extern void ADF4351_force_refresh(void); extern void ADF4351_CP(int p); +extern void ADF4351_modulo(int m); extern int SI4463_R; extern volatile int64_t ADF4350_modulo; extern void SI446x_set_AGC_LNA(uint8_t v); diff --git a/sa_core.c b/sa_core.c index 5a6e895..dcdace1 100644 --- a/sa_core.c +++ b/sa_core.c @@ -40,6 +40,8 @@ uint16_t actual_rbw_x10 = 0; uint16_t vbwSteps = 1; uint32_t minFreq = 0; uint32_t maxFreq = 520000000; +static unsigned long old_freq[5] = { 0, 0, 0, 0,0}; +static unsigned long real_old_freq[5] = { 0, 0, 0, 0,0}; //int setting.refer = -1; // Off by default const int reffer_freq[] = {30000000, 15000000, 10000000, 4000000, 3000000, 2000000, 1000000}; @@ -455,9 +457,9 @@ void set_R(int f) void set_modulo(uint32_t f) { - ADF4350_modulo = f; - //ADF4351_spur_mode(f); - dirty = true; + ADF4351_modulo(f); + ADF4351_force_refresh(); + ADF4351_set_frequency(0, real_old_freq[ADF4351_LO]); } #endif @@ -1171,8 +1173,6 @@ uint32_t peakFreq; int peakIndex; float temppeakLevel; int temppeakIndex; -static unsigned long old_freq[5] = { 0, 0, 0, 0,0}; -static unsigned long real_old_freq[5] = { 0, 0, 0, 0,0}; // volatile int t; //static uint32_t extra_vbw_step_time = 0; diff --git a/si4432.c b/si4432.c index dee60c8..29dc20e 100644 --- a/si4432.c +++ b/si4432.c @@ -1097,6 +1097,12 @@ void ADF4351_force_refresh(void) { prev_actual_freq = 0; } +void ADF4351_modulo(int m) +{ + ADF4350_modulo = m; +// ADF4351_set_frequency(0, (uint64_t)prev_actual_freq); +} + uint64_t ADF4351_set_frequency(int channel, uint64_t freq) // freq / 10Hz { // freq -= 71000;