# HG changeset patch # User Mychaela Falconia # Date 1495490436 0 # Node ID 0b6881281d865f2497216e09cde41d1526dfb6de # Parent 9a9fd9ebe799b35cda89cde7eed40d6446808fc9 fc-rfcal-vcxo ready for first test diff -r 9a9fd9ebe799 -r 0b6881281d86 autocal/Makefile --- a/autocal/Makefile Mon May 22 21:19:33 2017 +0000 +++ b/autocal/Makefile Mon May 22 22:00:36 2017 +0000 @@ -2,7 +2,7 @@ CFLAGS= -O2 -I/opt/freecalypso/include PROGS= fc-rfcal-vcxo -VCXO_OBJS= l1tmops.o rvinterf.o sockopts.o tsidsock.o vcxomain.o +VCXO_OBJS= l1tmops.o rvinterf.o sockopts.o tsidsock.o vcxomain.o vcxomeas.o all: ${PROGS} diff -r 9a9fd9ebe799 -r 0b6881281d86 autocal/vcxomain.c --- a/autocal/vcxomain.c Mon May 22 21:19:33 2017 +0000 +++ b/autocal/vcxomain.c Mon May 22 22:00:36 2017 +0000 @@ -12,6 +12,12 @@ #define VCXOCAL_BAND_RFPW RFPW_STD_BAND(6, 0) #define VCXOCAL_ARFCN 40 +extern float vcxo_freq_meas(); + +static float freq_max_neg, freq_max_pos; +static float lin_a, lin_b, lin_a2, lin_b2; +static int center_search_start; + prepare_rf_test_system() { char cmd[80]; @@ -39,5 +45,18 @@ printf("Starting RF Tx on the DUT\n"); do_rfe(RX_TX_TCH); + /* initial measurements at the DAC extremes */ + freq_max_neg = vcxo_freq_meas(-2048, "max-neg"); + freq_max_pos = vcxo_freq_meas(2048, "max-pos"); + lin_a = (freq_max_pos - freq_max_neg) / 4096.0f; + lin_b = freq_max_pos - lin_a * 2048.0f; + center_search_start = -lin_b / lin_a; + printf("Center search start DAC value: %d\n", center_search_start); + vcxo_freq_meas(center_search_start, "center"); + vcxo_freq_meas(center_search_start - 100, "center-delta"); + vcxo_freq_meas(center_search_start + 100, "center+delta"); + printf("Stopping RF Tx on the DUT\n"); + do_rfe(STOP_ALL); + exit(0); } diff -r 9a9fd9ebe799 -r 0b6881281d86 autocal/vcxomeas.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/autocal/vcxomeas.c Mon May 22 22:00:36 2017 +0000 @@ -0,0 +1,29 @@ +/* + * This module contains the frequency measurement code for fc-rfcal-vcxo. + */ + +#include +#include +#include +#include +#include + +extern char tsid_response[]; + +float +vcxo_freq_meas(dac, hint) + int dac; + char *hint; +{ + char cmd[80]; + double meas; + + printf("Performing frequency measurement at DAC=%d (%s)\n", dac, hint); + do_rfpw(AFC_DAC_VALUE, dac); + usleep(80000); + sprintf(cmd, "freq-meas %s\n", hint); + tsid_command(cmd); + atof(tsid_response + 1); + printf("Measured frequency offset %.2f Hz\n", meas); + return(meas); +}