FreeCalypso > hg > fc-rfcal-tools
changeset 24:0b6881281d86
fc-rfcal-vcxo ready for first test
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 22 May 2017 22:00:36 +0000 |
parents | 9a9fd9ebe799 |
children | 5226dbaa5333 |
files | autocal/Makefile autocal/vcxomain.c autocal/vcxomeas.c |
diffstat | 3 files changed, 49 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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}
--- 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); }
--- /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 <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <rvinterf/l1tm.h> +#include <rvinterf/exitcodes.h> + +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); +}