avoid irregular spurs

SI443_RBW_update
erikkaashoek 4 years ago
parent 23d9d258da
commit a800e405f1

@ -3654,7 +3654,7 @@ again: // Spur redu
if (local_modulo == 0) ADF4351_modulo(4000); if (local_modulo == 0) ADF4351_modulo(4000);
freq_t tf = ((lf + actual_rbw_x10*200) / TXCO_DIV3) * TXCO_DIV3; 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); ADF4350_shift_ref(true);
} else { } else {
ADF4350_shift_ref(false); ADF4350_shift_ref(false);
@ -3675,7 +3675,7 @@ again: // Spur redu
} else { } else {
freq_t tf = ((lf + actual_rbw_x10*200) / TXCO_DIV3) * TXCO_DIV3; 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); ADF4350_shift_ref(true);
} else { } else {
ADF4350_shift_ref(false); ADF4350_shift_ref(false);
@ -4041,6 +4041,13 @@ again: // Spur redu
} }
#endif #endif
if (!in_step_test) { 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 (old_R >= 5) {
if (my_step_delay <500) if (my_step_delay <500)
my_step_delay *= 6; my_step_delay *= 6;

@ -312,7 +312,7 @@ void ADF4351_Setup(void)
#ifdef __SI5351__ #ifdef __SI5351__
si5351_available = si5351_init(); si5351_available = si5351_init();
if (si5351_available) if (si5351_available)
si5351_set_frequency(0, 29999000, 0); si5351_set_frequency(0, 30000000, 0);
#endif #endif
// SPI3_CLK_HIGH; // SPI3_CLK_HIGH;
@ -444,24 +444,30 @@ void ADF4351_R_counter(int R)
void ADF4351_recalculate_PFDRFout(void){ void ADF4351_recalculate_PFDRFout(void){
int local_r = old_R; int local_r = old_R;
old_R = -1; 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); ADF4351_R_counter(local_r);
} }
#ifdef __SI5351__ #ifdef __SI5351__
static int shifted = -2; static int shifted = -2;
#define SHIFT_MUL 31
#define SHIFT_DIV 29
#define SHIFT_FACTOR 100000
void ADF4350_shift_ref(int f) { void ADF4350_shift_ref(int f) {
if (f == shifted) if (f == shifted)
return; return;
shifted = f; shifted = false;
if (f)
local_setting_frequency_30mhz_x100 = 2999000000;
else
local_setting_frequency_30mhz_x100 = 3000000000; 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
si5351_set_int_mul_div(0, 30, 30, 0);
ADF4351_recalculate_PFDRFout(); ADF4351_recalculate_PFDRFout();
shifted = f;
} }
#endif #endif
@ -1735,10 +1741,10 @@ freq_t SI4463_set_freq(freq_t freq)
si_set_offset(0); si_set_offset(0);
SI4463_offset_active = false; 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 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; 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*local_setting_frequency_30mhz_x100 : 4*local_setting_frequency_30mhz_x100)/ output_divider/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 #if 0 // Only for debugging
int delta = freq - actual_freq; int delta = freq - actual_freq;
if (delta < -100 || delta > 100 ){ if (delta < -100 || delta > 100 ){

@ -246,7 +246,7 @@ bool si5351_init(void)
{ {
if (!si5351_wait_ready()) if (!si5351_wait_ready())
return false; return false;
my_microsecond_delay(200); // my_microsecond_delay(200);
const uint8_t *p = si5351_configs; const uint8_t *p = si5351_configs;
while (*p) { while (*p) {
uint8_t len = *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) void si5351_set_frequency(int channel, int freq, uint8_t drive_strength)
{ {
if (freq <= 100000000) { if (freq <= 100000000) {
si5351_setupPLL(SI5351_PLL_B, 30, 0, 1); si5351_setupPLL(SI5351_PLL_A, 30, 0, 1);
si5351_set_frequency_fixedpll(channel, SI5351_PLL_B, PLLFREQ, freq, SI5351_R_DIV_1, drive_strength); si5351_set_frequency_fixedpll(channel, SI5351_PLL_A, PLLFREQ, freq, SI5351_R_DIV_1, drive_strength);
} else if (freq < 150000000) { } 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 { } 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; static int current_band = -1;

@ -81,6 +81,7 @@
bool si5351_init(void); bool si5351_init(void);
void si5351_set_frequency(int channel, int freq, uint8_t drive_strength); 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); 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; extern char pll_lock_failed;
#endif //__SI5351_H__ #endif //__SI5351_H__

Loading…
Cancel
Save

Powered by TurnKey Linux.