FreeCalypso > hg > fc-rfcal-tools
comparison autocal/txbasis.c @ 101:b0618796d28d
fc-rfcal-txband: added safety checks for NaN power measurements and
out-of-tolerance final Tx power levels
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 11 Aug 2017 03:20:43 +0000 |
parents | 83b24a1dfd4a |
children | 7ad0495991ed |
comparison
equal
deleted
inserted
replaced
100:7ad5836d3b87 | 101:b0618796d28d |
---|---|
1 /* | 1 /* |
2 * The basis steps of Tx power level calibration are implemented here. | 2 * The basis steps of Tx power level calibration are implemented here. |
3 */ | 3 */ |
4 | 4 |
5 #include <math.h> | |
5 #include <stdio.h> | 6 #include <stdio.h> |
6 #include <stdlib.h> | 7 #include <stdlib.h> |
7 #include <rvinterf/l1tm.h> | 8 #include <rvinterf/l1tm.h> |
8 #include <rvinterf/exitcodes.h> | 9 #include <rvinterf/exitcodes.h> |
9 #include "txband.h" | 10 #include "txband.h" |
17 | 18 |
18 txcal_basis_run() | 19 txcal_basis_run() |
19 { | 20 { |
20 unsigned n; | 21 unsigned n; |
21 double meas; | 22 double meas; |
23 int nanflag = 0; | |
22 | 24 |
23 printf("Performing the calibration basis run\n"); | 25 printf("Performing the calibration basis run\n"); |
24 do_txpw(TX_PWR_LEVEL, txcal_band->start_plnum); | 26 do_txpw(TX_PWR_LEVEL, txcal_band->start_plnum); |
25 printf("Starting RF Tx on the DUT\n"); | 27 printf("Starting RF Tx on the DUT\n"); |
26 do_rfe(RX_TX_TCH); | 28 do_rfe(RX_TX_TCH); |
28 for (n = 0; n < num_basis_points; n++) { | 30 for (n = 0; n < num_basis_points; n++) { |
29 do_txpw(TX_APC_DAC, tx_basis[n].apc); | 31 do_txpw(TX_APC_DAC, tx_basis[n].apc); |
30 usleep(20000); | 32 usleep(20000); |
31 meas = tx_power_meas(); | 33 meas = tx_power_meas(); |
32 printf("APC DAC=%u: %.2f dBm\n", tx_basis[n].apc, meas); | 34 printf("APC DAC=%u: %.2f dBm\n", tx_basis[n].apc, meas); |
35 if (isnan(meas)) | |
36 nanflag = 1; | |
33 tx_basis[n].vout = dbm_to_vout(meas); | 37 tx_basis[n].vout = dbm_to_vout(meas); |
34 } | 38 } |
35 | 39 |
36 printf("Stopping RF Tx on the DUT\n"); | 40 printf("Stopping RF Tx on the DUT\n"); |
37 do_rfe(STOP_ALL); | 41 do_rfe(STOP_ALL); |
42 if (nanflag) { | |
43 printf("Error: got NaN power measurement, aborting\n"); | |
44 exit(ERROR_TARGET); | |
45 } | |
38 return(0); | 46 return(0); |
39 } | 47 } |
40 | 48 |
41 txcal_basis_compute() | 49 txcal_basis_compute() |
42 { | 50 { |
45 for (n = 0; n < num_basis_points - 1; n++) { | 53 for (n = 0; n < num_basis_points - 1; n++) { |
46 if (tx_basis[n+1].vout <= tx_basis[n].vout) { | 54 if (tx_basis[n+1].vout <= tx_basis[n].vout) { |
47 fprintf(stderr, | 55 fprintf(stderr, |
48 "error: Vout at APC=%u is not greater than at APC=%u\n", | 56 "error: Vout at APC=%u is not greater than at APC=%u\n", |
49 tx_basis[n+1].apc, tx_basis[n].apc); | 57 tx_basis[n+1].apc, tx_basis[n].apc); |
50 exit(ERROR_RFTEST); | 58 exit(ERROR_TARGET); |
51 } | 59 } |
52 tx_basis[n].slope = (tx_basis[n+1].vout - tx_basis[n].vout) / | 60 tx_basis[n].slope = (tx_basis[n+1].vout - tx_basis[n].vout) / |
53 (tx_basis[n+1].apc - tx_basis[n].apc); | 61 (tx_basis[n+1].apc - tx_basis[n].apc); |
54 } | 62 } |
55 return(0); | 63 return(0); |