# HG changeset patch # User Mychaela Falconia # Date 1500160186 0 # Node ID 45ef4a06edfcbbbda9faee3160a58b1d75ec9041 # Parent a094db1453b1c190140bfc4fea35c31ee0790bac fc-rfcal-txband: initial implementation complete, ready to test diff -r a094db1453b1 -r 45ef4a06edfc autocal/txbandmain.c --- a/autocal/txbandmain.c Sat Jul 15 22:48:29 2017 +0000 +++ b/autocal/txbandmain.c Sat Jul 15 23:09:46 2017 +0000 @@ -122,6 +122,8 @@ txcal_basis_run(); /* analytical follow-up */ txcal_basis_compute(); - + /* actual Tx levels calibration */ + calibrate_tx_levels(); + exit(0); } diff -r a094db1453b1 -r 45ef4a06edfc autocal/txlevels.c --- a/autocal/txlevels.c Sat Jul 15 22:48:29 2017 +0000 +++ b/autocal/txlevels.c Sat Jul 15 23:09:46 2017 +0000 @@ -17,8 +17,9 @@ extern struct tx_level tx_levels[MAX_TX_LEVELS]; unsigned -find_apc_for_target(target_dbm) +find_apc_for_target(target_dbm, pslope) double target_dbm; + vout_t *pslope; { vout_t target_vout; unsigned n; @@ -28,6 +29,37 @@ for (n = 0; n < num_basis_points - 1; n++) if (target_vout < tx_basis[n+1].vout) break; + if (pslope) + *pslope = tx_basis[n].slope; apc_delta = (target_vout - tx_basis[n].vout) / tx_basis[n].slope; return tx_basis[n].apc + apc_delta; } + +calibrate_tx_levels() +{ + unsigned plnum, plidx, apc; + double target, meas; + + printf("Calibrating Tx power levels\n"); + printf("Starting RF Tx on the DUT\n"); + do_rfe(RX_TX_TCH); + + for (plnum = txcal_band->start_plnum; plnum <= txcal_band->end_plnum; + plnum++) { + do_txpw(TX_PWR_LEVEL, plnum); + plidx = plnum = txcal_band->start_plnum; + target = tx_levels[plidx].target; + apc = find_apc_for_target(target, &tx_levels[plidx].slope); + tx_levels[plidx].apc = apc; + do_txpw(TX_APC_DAC, apc); + usleep(20000); + meas = tx_power_meas(); + printf( + "Tx power level #%u: target %.1f dBm, APC=%u, meas %.2f dBm (%+.2f)\n", + plnum, target, apc, meas, meas - target); + } + + printf("Stopping RF Tx on the DUT\n"); + do_rfe(STOP_ALL); + return(0); +}