FreeCalypso > hg > fc-rfcal-tools
comparison autocal/txcalchan.c @ 116:4ce87a30383f
fc-rfcal-txband: channel calibration implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 13 Feb 2018 06:22:32 +0000 |
parents | 3f63e71b6422 |
children | 4c3f4231a021 |
comparison
equal
deleted
inserted
replaced
115:1e49bb52b07e | 116:4ce87a30383f |
---|---|
9 #include <rvinterf/l1tm.h> | 9 #include <rvinterf/l1tm.h> |
10 #include <rvinterf/exitcodes.h> | 10 #include <rvinterf/exitcodes.h> |
11 #include "txband.h" | 11 #include "txband.h" |
12 #include "txcalchan.h" | 12 #include "txcalchan.h" |
13 | 13 |
14 extern double tx_power_meas(); | |
15 extern vout_t dbm_to_vout(); | |
16 | |
14 extern struct txcal_band *txcal_band; | 17 extern struct txcal_band *txcal_band; |
18 extern struct tx_level tx_levels[MAX_TX_LEVELS]; | |
15 | 19 |
16 unsigned tx_calchan_values[TX_CALCHAN_TABLES][TX_CALCHAN_ENTRIES]; | 20 unsigned tx_calchan_values[TX_CALCHAN_TABLES][TX_CALCHAN_ENTRIES]; |
17 | 21 |
18 init_tx_calchan() | 22 init_tx_calchan() |
19 { | 23 { |
21 | 25 |
22 for (i = 0; i < TX_CALCHAN_TABLES; i++) | 26 for (i = 0; i < TX_CALCHAN_TABLES; i++) |
23 for (j = 0; j < TX_CALCHAN_ENTRIES; j++) | 27 for (j = 0; j < TX_CALCHAN_ENTRIES; j++) |
24 tx_calchan_values[i][j] = 128; | 28 tx_calchan_values[i][j] = 128; |
25 return(0); | 29 return(0); |
30 } | |
31 | |
32 tx_calchan_one_table(tblnum) | |
33 unsigned tblnum; | |
34 { | |
35 vout_t vout[TX_CALCHAN_ENTRIES]; | |
36 char cmd[80]; | |
37 unsigned n, arfcn, plidx; | |
38 double meas; | |
39 int nanflag = 0; | |
40 int apc_delta; | |
41 unsigned apc_wanted; | |
42 | |
43 printf("Calibrating Tx channel correction table %u (PL #%u)\n", tblnum, | |
44 txcal_band->calchan_plnum[tblnum]); | |
45 do_txpw(TX_PWR_LEVEL, txcal_band->calchan_plnum[tblnum]); | |
46 plidx = txcal_band->calchan_plnum[tblnum] - txcal_band->start_plnum; | |
47 printf("Starting RF Tx on the DUT\n"); | |
48 do_rfe(RX_TX_TCH); | |
49 for (n = 0; n < TX_CALCHAN_ENTRIES; n++) { | |
50 arfcn = txcal_band->calchan_ranges[n].test_arfcn; | |
51 sprintf(cmd, "txpwr-cal-channel %u\n", arfcn); | |
52 tsid_command(cmd); | |
53 do_rfpw(TCH_ARFCN, arfcn); | |
54 usleep(20000); | |
55 meas = tx_power_meas(); | |
56 printf("ARFCN=%u: %.2f dBm\n", arfcn, meas); | |
57 if (isnan(meas)) | |
58 nanflag = 1; | |
59 vout[n] = dbm_to_vout(meas); | |
60 } | |
61 printf("Stopping RF Tx on the DUT\n"); | |
62 do_rfe(STOP_ALL); | |
63 if (nanflag) { | |
64 printf("Error: got NaN power measurement, aborting\n"); | |
65 exit(ERROR_RFFAIL); | |
66 } | |
67 | |
68 for (n = 0; n < TX_CALCHAN_ENTRIES; n++) { | |
69 apc_delta = (vout[txcal_band->ref_subband] - vout[n]) / | |
70 tx_levels[plidx].slope; | |
71 apc_wanted = tx_levels[plidx].apc + apc_delta; | |
72 tx_calchan_values[tblnum][n] = (apc_wanted * 128) / | |
73 tx_levels[plidx].apc; | |
74 printf("ARFCN %u-%u: correction=%u\n", | |
75 txcal_band->calchan_ranges[n].lower_bound, | |
76 txcal_band->calchan_ranges[n].upper_bound, | |
77 tx_calchan_values[tblnum][n]); | |
78 } | |
79 } | |
80 | |
81 calibrate_tx_calchan() | |
82 { | |
83 unsigned tblnum; | |
84 | |
85 for (tblnum = 0; tblnum < TX_CALCHAN_TABLES; tblnum++) | |
86 tx_calchan_one_table(tblnum); | |
26 } | 87 } |
27 | 88 |
28 upload_tx_calchan() | 89 upload_tx_calchan() |
29 { | 90 { |
30 unsigned i, j; | 91 unsigned i, j; |