diff --git a/Software/VNA_embedded/Application/Drivers/FPGA/FPGA.cpp b/Software/VNA_embedded/Application/Drivers/FPGA/FPGA.cpp index 414f97a..654d545 100644 --- a/Software/VNA_embedded/Application/Drivers/FPGA/FPGA.cpp +++ b/Software/VNA_embedded/Application/Drivers/FPGA/FPGA.cpp @@ -137,6 +137,14 @@ void FPGA::Disable(Periphery p) { WriteRegister(Reg::SystemControl, SysCtrlReg); } +bool FPGA::IsEnabled(Periphery p) { + if(SysCtrlReg & (uint16_t) p) { + return true; + } else { + return false; + } +} + void FPGA::SetWindow(Window w) { SysCtrlReg &= ~0x0060; SysCtrlReg |= (int) w << 5; diff --git a/Software/VNA_embedded/Application/Drivers/FPGA/FPGA.hpp b/Software/VNA_embedded/Application/Drivers/FPGA/FPGA.hpp index 5ddfdf3..ce6aa34 100644 --- a/Software/VNA_embedded/Application/Drivers/FPGA/FPGA.hpp +++ b/Software/VNA_embedded/Application/Drivers/FPGA/FPGA.hpp @@ -103,6 +103,7 @@ void SetNumberOfPoints(uint16_t npoints); void SetSamplesPerPoint(uint32_t nsamples); void Enable(Periphery p, bool enable = true); void Disable(Periphery p); +bool IsEnabled(Periphery p); void SetWindow(Window w); void EnableInterrupt(Interrupt i); void DisableInterrupt(Interrupt i); diff --git a/Software/VNA_embedded/Application/VNA.cpp b/Software/VNA_embedded/Application/VNA.cpp index 5086a6c..ee1e7ce 100644 --- a/Software/VNA_embedded/Application/VNA.cpp +++ b/Software/VNA_embedded/Application/VNA.cpp @@ -259,7 +259,7 @@ void VNA::SweepHalted() { Si5351.Enable(SiChannel::LowbandSource); FPGA::Disable(FPGA::Periphery::SourceRF); } - } else { + } else if(!FPGA::IsEnabled(FPGA::Periphery::SourceRF)){ // first sweep point in highband is also halted, disable lowband source Si5351.Disable(SiChannel::LowbandSource); FPGA::Enable(FPGA::Periphery::SourceRF);