comparison 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
comparison
equal deleted inserted replaced
99:b06532c9642f 100:7ad5836d3b87
19 extern float vcxo_freq_meas(); 19 extern float vcxo_freq_meas();
20 20
21 static float freq_max_neg, freq_max_pos; 21 static float freq_max_neg, freq_max_pos;
22 static float lin_a, lin_b, lin_a2, lin_b2; 22 static float lin_a, lin_b, lin_a2, lin_b2;
23 static int zero_search_dac1, zero_search_dac2, zero_search_incr; 23 static int zero_search_dac1, zero_search_dac2, zero_search_incr;
24 static float zero_search_freq1, zero_search_freq2; 24 static float zero_search_freq1, zero_search_freq2, zero_check_freq;
25 static float dac_min, dac_max, dac_init; 25 static float dac_min, dac_max, dac_init;
26 static int dac_init_int; 26 static int dac_init_int;
27 static float Psi_sta, Psi_st; 27 static float Psi_sta, Psi_st;
28 28
29 struct afcparams afcparams_host, afcparams_arm; 29 struct afcparams afcparams_host, afcparams_arm;
91 dac_max = (13500.0f - lin_b) / lin_a; 91 dac_max = (13500.0f - lin_b) / lin_a;
92 dac_init = -lin_b2 / lin_a2; 92 dac_init = -lin_b2 / lin_a2;
93 dac_init_int = (int) dac_init; 93 dac_init_int = (int) dac_init;
94 94
95 /* check the frequency offset at the final DAC value */ 95 /* check the frequency offset at the final DAC value */
96 vcxo_freq_meas(dac_init_int, "zero-check"); 96 zero_check_freq = vcxo_freq_meas(dac_init_int, "zero-check");
97 97
98 /* done with the measurements and the Tx */ 98 /* done with the measurements and the Tx */
99 printf("Stopping RF Tx on the DUT\n"); 99 printf("Stopping RF Tx on the DUT\n");
100 do_rfe(STOP_ALL); 100 do_rfe(STOP_ALL);
101
102 /* sanity check */
103 if (zero_check_freq < -70.0f || zero_check_freq > 70.0f) {
104 printf("Error: final freq offset out of range, aborting\n");
105 exit(ERROR_TARGET);
106 }
101 107
102 /* Psi computations */ 108 /* Psi computations */
103 Psi_sta = 2.0f * (float)M_PI * lin_a / 270833.0f; 109 Psi_sta = 2.0f * (float)M_PI * lin_a / 270833.0f;
104 Psi_st = Psi_sta * 0.8f; 110 Psi_st = Psi_sta * 0.8f;
105 111