diff autocal/vcxomain.c @ 100:7ad5836d3b87

fc-rfcal-vcxo: added check for final freq offset being within 70 Hz
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 11 Aug 2017 02:45:10 +0000
parents 6e8f2728c7f5
children 7ad0495991ed
line wrap: on
line diff
--- a/autocal/vcxomain.c	Fri Aug 11 02:21:32 2017 +0000
+++ b/autocal/vcxomain.c	Fri Aug 11 02:45:10 2017 +0000
@@ -21,7 +21,7 @@
 static float freq_max_neg, freq_max_pos;
 static float lin_a, lin_b, lin_a2, lin_b2;
 static int zero_search_dac1, zero_search_dac2, zero_search_incr;
-static float zero_search_freq1, zero_search_freq2;
+static float zero_search_freq1, zero_search_freq2, zero_check_freq;
 static float dac_min, dac_max, dac_init;
 static int dac_init_int;
 static float Psi_sta, Psi_st;
@@ -93,12 +93,18 @@
 	dac_init_int = (int) dac_init;
 
 	/* check the frequency offset at the final DAC value */
-	vcxo_freq_meas(dac_init_int, "zero-check");
+	zero_check_freq = vcxo_freq_meas(dac_init_int, "zero-check");
 
 	/* done with the measurements and the Tx */
 	printf("Stopping RF Tx on the DUT\n");
 	do_rfe(STOP_ALL);
 
+	/* sanity check */
+	if (zero_check_freq < -70.0f || zero_check_freq > 70.0f) {
+		printf("Error: final freq offset out of range, aborting\n");
+		exit(ERROR_TARGET);
+	}
+
 	/* Psi computations */
 	Psi_sta = 2.0f * (float)M_PI * lin_a / 270833.0f;
 	Psi_st = Psi_sta * 0.8f;