diff --git a/sa_core.c b/sa_core.c index 872d585..6c38874 100644 --- a/sa_core.c +++ b/sa_core.c @@ -3654,7 +3654,7 @@ again: // Spur redu if (local_modulo == 0) ADF4351_modulo(4000); freq_t tf = ((lf + actual_rbw_x10*200) / TXCO_DIV3) * TXCO_DIV3; - if (tf + actual_rbw_x10*200 >= lf && tf < lf + actual_rbw_x10*200) { // 10MHz + if (tf + actual_rbw_x10*200 >= lf && tf < lf + actual_rbw_x10*200 && actual_rbw_x10 < 300) { // 10MHz ADF4350_shift_ref(true); } else { ADF4350_shift_ref(false); @@ -3675,7 +3675,7 @@ again: // Spur redu } else { freq_t tf = ((lf + actual_rbw_x10*200) / TXCO_DIV3) * TXCO_DIV3; - if (tf + actual_rbw_x10*200 >= lf && tf < lf + actual_rbw_x10*200) { // 30MHz + if (tf + actual_rbw_x10*200 >= lf && tf < lf + actual_rbw_x10*200 && actual_rbw_x10 < 300) { // 30MHz ADF4350_shift_ref(true); } else { ADF4350_shift_ref(false); @@ -4041,6 +4041,13 @@ again: // Spur redu } #endif if (!in_step_test) { + if (my_step_delay < 250) { + if ((134000000 < lf && lf <142000000) || + (161400000 < lf && lf <163400000) || + (182800000 < lf && lf <184800000) || + (206000000 < lf && lf <207000000) ) + my_step_delay = 300; + } if (old_R >= 5) { if (my_step_delay <500) my_step_delay *= 6; diff --git a/si4468.c b/si4468.c index 59dd77e..b860b40 100644 --- a/si4468.c +++ b/si4468.c @@ -312,7 +312,7 @@ void ADF4351_Setup(void) #ifdef __SI5351__ si5351_available = si5351_init(); if (si5351_available) - si5351_set_frequency(0, 29999000, 0); + si5351_set_frequency(0, 30000000, 0); #endif // SPI3_CLK_HIGH; @@ -444,24 +444,30 @@ void ADF4351_R_counter(int R) void ADF4351_recalculate_PFDRFout(void){ int local_r = old_R; old_R = -1; -#ifdef __SI5351__ - if (si5351_available) - si5351_set_frequency(0, local_setting_frequency_30mhz_x100/100, 0); -#endif ADF4351_R_counter(local_r); } #ifdef __SI5351__ static int shifted = -2; + +#define SHIFT_MUL 31 +#define SHIFT_DIV 29 + +#define SHIFT_FACTOR 100000 void ADF4350_shift_ref(int f) { if (f == shifted) return; - shifted = f; - if (f) - local_setting_frequency_30mhz_x100 = 2999000000; + shifted = false; + local_setting_frequency_30mhz_x100 = 3000000000; + if (shifted) { + local_setting_frequency_30mhz_x100 = (local_setting_frequency_30mhz_x100 * SHIFT_MUL) / SHIFT_DIV; + } + if (si5351_available && shifted) + si5351_set_int_mul_div(0, SHIFT_MUL, SHIFT_DIV, 0); else - local_setting_frequency_30mhz_x100 = 3000000000; + si5351_set_int_mul_div(0, 30, 30, 0); ADF4351_recalculate_PFDRFout(); + shifted = f; } #endif @@ -1735,10 +1741,10 @@ freq_t SI4463_set_freq(freq_t freq) si_set_offset(0); SI4463_offset_active = false; } - uint32_t R = (freq * output_divider) / (Npresc ? 2*local_setting_frequency_30mhz_x100 : 4*local_setting_frequency_30mhz_x100) - 1; // R between 0x00 and 0x7f (127) + uint32_t R = (freq * output_divider) / (Npresc ? 2*config.setting_frequency_30mhz : 4*config.setting_frequency_30mhz) - 1; // R between 0x00 and 0x7f (127) uint64_t MOD = 524288; // = 2^19 - uint32_t F = ((freq * output_divider*MOD) / (Npresc ? 2*local_setting_frequency_30mhz_x100 : 4*local_setting_frequency_30mhz_x100)) - R*MOD; - freq_t actual_freq = (R*MOD + F) * (Npresc ? 2*local_setting_frequency_30mhz_x100 : 4*local_setting_frequency_30mhz_x100)/ output_divider/MOD; + uint32_t F = ((freq * output_divider*MOD) / (Npresc ? 2*config.setting_frequency_30mhz : 4*config.setting_frequency_30mhz)) - R*MOD; + freq_t actual_freq = (R*MOD + F) * (Npresc ? 2*config.setting_frequency_30mhz : 4*config.setting_frequency_30mhz)/ output_divider/MOD; #if 0 // Only for debugging int delta = freq - actual_freq; if (delta < -100 || delta > 100 ){ diff --git a/si5351.c b/si5351.c index b71d031..de517e0 100644 --- a/si5351.c +++ b/si5351.c @@ -246,7 +246,7 @@ bool si5351_init(void) { if (!si5351_wait_ready()) return false; - my_microsecond_delay(200); +// my_microsecond_delay(200); const uint8_t *p = si5351_configs; while (*p) { uint8_t len = *p++; @@ -478,15 +478,20 @@ static void si5351_set_frequency_fixeddiv( void si5351_set_frequency(int channel, int freq, uint8_t drive_strength) { if (freq <= 100000000) { - si5351_setupPLL(SI5351_PLL_B, 30, 0, 1); - si5351_set_frequency_fixedpll(channel, SI5351_PLL_B, PLLFREQ, freq, SI5351_R_DIV_1, drive_strength); + si5351_setupPLL(SI5351_PLL_A, 30, 0, 1); + si5351_set_frequency_fixedpll(channel, SI5351_PLL_A, PLLFREQ, freq, SI5351_R_DIV_1, drive_strength); } else if (freq < 150000000) { - si5351_set_frequency_fixeddiv(channel, SI5351_PLL_B, freq, 6, drive_strength); + si5351_set_frequency_fixeddiv(channel, SI5351_PLL_A, freq, 6, drive_strength); } else { - si5351_set_frequency_fixeddiv(channel, SI5351_PLL_B, freq, 4, drive_strength); + si5351_set_frequency_fixeddiv(channel, SI5351_PLL_A, freq, 4, drive_strength); } } +void si5351_set_int_mul_div(int channel, int multi, int div, uint8_t drive_strength) +{ + si5351_setupPLL(SI5351_PLL_A, multi, 0, 1); + si5351_setupMultisynth(channel, SI5351_PLL_A, div, 0, 1, SI5351_R_DIV_1, drive_strength); +} static int current_band = -1; diff --git a/si5351.h b/si5351.h index 6ebe3b1..03370ec 100644 --- a/si5351.h +++ b/si5351.h @@ -81,6 +81,7 @@ bool si5351_init(void); void si5351_set_frequency(int channel, int freq, uint8_t drive_strength); int si5351_set_frequency_with_offset(uint32_t freq, int offset, uint8_t drive_strength); +void si5351_set_int_mul_div(int channel, int multi, int div, uint8_t drive_strength); extern char pll_lock_failed; #endif //__SI5351_H__