diff --git a/firmware/command_ctrl.ino b/firmware/command_ctrl.ino index a031293..7ecd625 100644 --- a/firmware/command_ctrl.ino +++ b/firmware/command_ctrl.ino @@ -222,6 +222,12 @@ void cc_startMeasurement() uint32_t freq = 0; for (freq = start_freq; freq <= end_freq; freq += step_freq) { + if (freq > end_freq) + { + // prevent to step over the end frequency + // maybe the user is not allowed to send data in the frequency band + freq = end_freq; + } uint32_t a0_sum = 0; uint32_t a1_sum = 0; uint16_t i = 0; @@ -268,6 +274,9 @@ void cc_startMeasurement() Serial.write(MSG_EOM2); si5351.output_enable(SI5351_CLK0, 0); // disable clock output 0 + + if (freq >= end_freq) + break; // abort the loop because all is done } // 5. send a measurement end message to the host