From 0cecaf72e5a7b1ee2ecc81fd11d72b7cf27e7d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Mon, 6 Jun 2022 17:28:03 +0200 Subject: [PATCH] Prevent higher frequency output spike when sweep starts at DC --- .../.settings/stm32cubeide.project.prefs | 4 ++-- Software/VNA_embedded/Application/VNA.cpp | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Software/VNA_embedded/.settings/stm32cubeide.project.prefs b/Software/VNA_embedded/.settings/stm32cubeide.project.prefs index 586dde5..60e3eec 100644 --- a/Software/VNA_embedded/.settings/stm32cubeide.project.prefs +++ b/Software/VNA_embedded/.settings/stm32cubeide.project.prefs @@ -1,5 +1,5 @@ -2F62501ED4689FB349E356AB974DBE57=EF826FD321FB312AEADE4DB74B81458C +2F62501ED4689FB349E356AB974DBE57=6F84FD31C089E822CF61FFCABCD0B7D1 66BE74F758C12D739921AEA421D593D3=2 -8DF89ED150041C4CBC7CB9A9CAA90856=EF826FD321FB312AEADE4DB74B81458C +8DF89ED150041C4CBC7CB9A9CAA90856=6F84FD31C089E822CF61FFCABCD0B7D1 DC22A860405A8BF2F2C095E5B6529F12=6E2D4146EA2709ED1E4A1764BC291F57 eclipse.preferences.version=1 diff --git a/Software/VNA_embedded/Application/VNA.cpp b/Software/VNA_embedded/Application/VNA.cpp index 4e3e4e5..52cf778 100644 --- a/Software/VNA_embedded/Application/VNA.cpp +++ b/Software/VNA_embedded/Application/VNA.cpp @@ -404,12 +404,18 @@ void VNA::SweepHalted() { } // need the Si5351 as Source - Si5351.SetCLK(SiChannel::LowbandSource, frequency, Si5351C::PLL::B, driveStrength); + bool freqSuccess = Si5351.SetCLK(SiChannel::LowbandSource, frequency, Si5351C::PLL::B, driveStrength); + static bool lowbandDisabled = false; if (pointCnt == 0) { - // First point in sweep, enable CLK - Si5351.Enable(SiChannel::LowbandSource); + // First point in sweep, switch to correct source FPGA::Disable(FPGA::Periphery::SourceRF); + lowbandDisabled = true; + } + if(lowbandDisabled && freqSuccess) { + // frequency is valid, can enable lowband source now + Si5351.Enable(SiChannel::LowbandSource); Delay::us(1300); + lowbandDisabled = false; } // At low frequencies the 1.LO feedthrough mixes with the 2.LO in the second mixer.