From fae783f2a9841073dcaf011e6b31a28fcaab1b35 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Sun, 11 Oct 2020 16:21:15 +0200 Subject: [PATCH] Working!!!! --- main.c | 3 ++- sa_core.c | 42 +++++++++++++++++++++++------------------- si4432.c | 2 +- si4432.h | 4 ++-- ui_sa.c | 1 + 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/main.c b/main.c index 13bbd40..a9af0cd 100644 --- a/main.c +++ b/main.c @@ -873,10 +873,11 @@ config_t config = { .harmonic_freq_threshold = 300000000, #endif .vbat_offset = 500, + .frequency_IF2 = 2048600000, .low_level_offset = 100, // Uncalibrated .high_level_offset = 100, // Uncalibrated .correction_frequency = { 10000, 100000, 200000, 500000, 50000000, 140000000, 200000000, 300000000, 330000000, 350000000 }, - .correction_value = { +6.0, +2.8, +1.6, -0.4, 0.0, -0.4, +0.4, +3.0, +4.0, +8.1 }, + .correction_value = { 0, 0, 0, 0, 0.0, 0, 0, 0, 0, 0 }, .cor_am = -14, .cor_wfm = -17, .cor_nfm = -17, diff --git a/sa_core.c b/sa_core.c index fbdfcba..e0ae891 100644 --- a/sa_core.c +++ b/sa_core.c @@ -67,7 +67,10 @@ void update_min_max_freq(void) switch(setting.mode) { case M_LOW: minFreq = 0; - maxFreq = 350000000; + if (config.frequency_IF2 == 0) + maxFreq = 350000000; + else + maxFreq = config.frequency_IF2; break; #ifdef __ULTRA__ case M_ULTRA: @@ -132,7 +135,7 @@ void reset_settings(int m) setting.repeat = 1; setting.tracking_output = false; setting.measurement = M_OFF; - setting.frequency_IF = 433800000; + setting.frequency_IF = 433600000; setting.auto_IF = true; setting.offset = 0.0; setting.trigger = T_AUTO; @@ -386,6 +389,7 @@ void set_IF2(int f) config.frequency_IF2 = f; dirty = true; + config_save(); } #define POWER_STEP 0 // Should be 5 dB but appearently it is lower @@ -931,8 +935,8 @@ void calculate_step_delay(void) #endif #ifdef __SI4463__ if (actual_rbw_x10 >= 2700) { SI4432_step_delay = 400; SI4432_offset_delay = 100; } - else if (actual_rbw_x10 >= 800) { SI4432_step_delay = 400; 150; SI4432_offset_delay = 100; } - else if (actual_rbw_x10 >= 250) { SI4432_step_delay = 1000; 450; SI4432_offset_delay = 100; } + else if (actual_rbw_x10 >= 800) { SI4432_step_delay = 500; SI4432_offset_delay = 100; } + else if (actual_rbw_x10 >= 250) { SI4432_step_delay = 1000; SI4432_offset_delay = 100; } else { SI4432_step_delay = 5000; SI4432_offset_delay =1600; } #endif if (setting.step_delay_mode == SD_PRECISE) // In precise mode wait twice as long for RSSI to stabalize @@ -1028,8 +1032,8 @@ uint32_t peakFreq; int peakIndex; float temppeakLevel; int temppeakIndex; -static unsigned long old_freq[4] = { 0, 0, 0, 0}; -static unsigned long real_old_freq[4] = { 0, 0, 0, 0}; +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; @@ -1042,10 +1046,10 @@ void setupSA(void) #ifdef __SI4432__ SI4432_Init(); #endif - old_freq[0] = 0; - old_freq[1] = 0; - real_old_freq[0] = 0; - real_old_freq[1] = 0; + for (int i = 0; i < sizeof(old_freq)/sizeof(unsigned long) ; i++) { + old_freq[i] = 0; + real_old_freq[i] = 0; + } #ifdef __SI4432__ SI4432_Sel = SI4432_RX ; SI4432_Receive(); @@ -1158,11 +1162,11 @@ void set_freq(int V, unsigned long freq) // translate the requested frequency } } if (freq) { - ADF4351_set_frequency(V-2,freq,3); + ADF4351_set_frequency(V-ADF4351_LO,freq,3); real_old_freq[V] = freq; } } else if (V==ADF4351_LO2){ - ADF4351_set_frequency(V-2,freq,3); + ADF4351_set_frequency(V-ADF4351_LO,freq,3); } else if (V==SI4463_RX) { if (setting.frequency_step<930000) // maximum step size is 937.49kHz @@ -1173,7 +1177,7 @@ void set_freq(int V, unsigned long freq) // translate the requested frequency } #ifdef __ULTRA_SA__ else { - ADF4351_set_frequency(V-2,freq,3); + ADF4351_set_frequency(V-ADF4351_LO,freq,3); } #endif old_freq[V] = freq; @@ -1443,11 +1447,11 @@ search_maximum(int m, int center, int span) } //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 = 433600000; // 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 int spur_table[] = // Frequencies to avoid { -#if 1 +#if 0 // 580000, // 433.8 MHz table // 880000, //? 960000, @@ -1765,7 +1769,7 @@ modulation_again: local_IF = 0; else { if (setting.auto_IF) - local_IF = setting.spur_removal ? 433900000 : spur_IF; + local_IF = setting.spur_removal ? 433600000 : spur_IF; else local_IF = setting.frequency_IF; } @@ -3329,7 +3333,7 @@ void test_prepare(int i) { setting.tracking = false; //Default test setup setting.atten_step = false; - setting.frequency_IF = 433800000; // Default frequency + setting.frequency_IF = 433600000; // Default frequency setting.auto_IF = true; setting.auto_attenuation = false; switch(test_case[i].setup) { // Prepare test conditions @@ -3481,7 +3485,7 @@ void self_test(int test) reset_settings(M_LOW); test_prepare(TEST_SILENCE); setting.auto_IF = false; - setting.frequency_IF=433000000; + setting.frequency_IF=433600000; setting.frequency_step = 30000; if (setting.test_argument > 0) setting.frequency_step=setting.test_argument; @@ -3541,7 +3545,7 @@ void self_test(int test) in_selftest = true; // reset_settings(M_LOW); setting.auto_IF = false; - setting.frequency_IF=433900000; + setting.frequency_IF=433600000; ui_mode_normal(); test_prepare(TEST_RBW); setting.step_delay = 8000; diff --git a/si4432.c b/si4432.c index 21be7e8..5cbbb0b 100644 --- a/si4432.c +++ b/si4432.c @@ -901,7 +901,7 @@ float Simulated_SI4432_RSSI(uint32_t i, int s) uint32_t registers[6] = {0xA00000, 0x8000011, 0x4E42, 0x4B3,0xDC003C , 0x580005} ; //10 MHz ref int debug = 0; -int ADF4351_LE[2] = { 10, 10}; +int ADF4351_LE[2] = { 10, 11}; int ADF4351_Mux = 7; diff --git a/si4432.h b/si4432.h index f869963..7c91004 100644 --- a/si4432.h +++ b/si4432.h @@ -184,9 +184,9 @@ extern const int SI4432_RBW_count; extern si446x_info_t SI4463_info; void Si446x_getInfo(si446x_info_t* info); void SI4463_init(void); -#define ADF4351_LO 2 +#define ADF4351_LO 3 #define ADF4351_LO2 4 -#define SI4463_RX 3 +#define SI4463_RX 2 #endif diff --git a/ui_sa.c b/ui_sa.c index 5ab2b4c..705e4a5 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -444,6 +444,7 @@ static const struct { {keypads_plusmin , "COR\nAM"}, // KM_COR_AM {keypads_plusmin , "COR\nWFM"}, // KM_COR_WFM {keypads_plusmin , "COR\nNFM"}, // KM_COR_NFM + {keypads_freq , "IF2"}, // KM_IF2 }; // ===[MENU CALLBACKS]=========================================================