From 9ab691f0811bf5f08162a6ecc47785ffad9692bc Mon Sep 17 00:00:00 2001 From: klaute Date: Mon, 10 Oct 2016 12:09:02 +0200 Subject: [PATCH] =?UTF-8?q?'firmware/command=5Fctrl.ino'=20=C3=A4ndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some for loop frequency range tests added to prevent a overrun of the specified frequence band. --- firmware/command_ctrl.ino | 9 +++++++++ 1 file changed, 9 insertions(+) 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