From: drowe67 Date: Tue, 9 Sep 2014 05:34:59 +0000 (+0000) Subject: test program to run rx for a while then dump scatter diagram data for plotting. ... X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=4e7e9bb12f525301a46c8a304c0b47f3a989ea43;p=freetel-svn-tracking.git test program to run rx for a while then dump scatter diagram data for plotting. Good results, 23-26dB SNR, nice tight scatter diagram git-svn-id: https://svn.code.sf.net/p/freetel/code@1836 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/stm32/Makefile b/codec2-dev/stm32/Makefile index b6f52e67..9fc660b2 100644 --- a/codec2-dev/stm32/Makefile +++ b/codec2-dev/stm32/Makefile @@ -109,7 +109,7 @@ OBJS = $(SRCS:.c=.o) ################################################### -all: libstm32f4.a codec2_profile.elf fft_test.elf dac_ut.elf dac_play.elf adc_rec.elf pwm_ut.elf fdmdv_profile.elf sm1000_leds_switches_ut.elf sm1000.elf adcdac_ut.elf freedv_tx_profile.elf freedv_rx_profile.elf adc_sd.elf usb_vcp_ut.elf +all: libstm32f4.a codec2_profile.elf fft_test.elf dac_ut.elf dac_play.elf adc_rec.elf pwm_ut.elf fdmdv_profile.elf sm1000_leds_switches_ut.elf sm1000.elf adcdac_ut.elf freedv_tx_profile.elf freedv_rx_profile.elf adc_sd.elf usb_vcp_ut.elf fdmdv_dump_rt.elf dl/$(PERIPHLIBZIP): mkdir -p dl @@ -331,6 +331,21 @@ FREEDV_RX_PROFILE_SRCS += $(CODEC2_SRCS) freedv_rx_profile.elf: $(FREEDV_RX_PROFILE_SRCS) $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) +FDMDV_DUMP_RT_SRCS=\ +src/fdmdv_dump_rt.c \ +src/sm1000_leds_switches.c \ +../src/fifo.c \ +src/debugblinky.c \ +gdb_stdio.c \ +src/system_stm32f4xx.c \ +src/startup_stm32f4xx.s \ +src/init.c + +FDMDV_DUMP_RT_SRCS += $(CODEC2_SRCS) + +fdmdv_dump_rt.elf: $(FDMDV_DUMP_RT_SRCS) src/stm32f4_dac.o src/stm32f4_adc.o + $(CC) $(CFLAGS) -O3 $^ -o $@ $(LIBPATHS) $(LIBS) + clean: rm -f *.o rm -f *.elf diff --git a/codec2-dev/stm32/src/fdmdv_dump_rt.c b/codec2-dev/stm32/src/fdmdv_dump_rt.c new file mode 100644 index 00000000..00cdccad --- /dev/null +++ b/codec2-dev/stm32/src/fdmdv_dump_rt.c @@ -0,0 +1,154 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: fdmdv_dump_rt.c + AUTHOR......: David Rowe + DATE CREATED: 9 Sep 2014 + + Runs the fdmdv demod in real time for a few seconds then dumps some + modem info to a text file for plotting in Octave. Way to verify the + "from radio" SM1000 hardware, ADC, and demod on the SM1000. + + Requires FreeDV signal to be sent to CN6 of SM1000. + + Octave: + + load scatter.txt + l=length(scatter) + plot(scatter(:,1:2:l),scatter(:,2:2:l),'+') + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2014 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. This program is + distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include +#include +#include +#include + +#include +#include "stm32f4_adc.h" +#include "stm32f4_dac.h" +#include "freedv_api.h" +#include "codec2_fdmdv.h" +#include "sm1000_leds_switches.h" +#include "gdb_stdio.h" + +#ifdef __EMBEDDED__ +#define printf gdb_stdio_printf +#define fprintf gdb_stdio_fprintf +#define fopen gdb_stdio_fopen +#define fclose gdb_stdio_fclose +#define fread gdb_stdio_fread +#define fwrite gdb_stdio_fwrite +#endif + +#define FREEDV_NSAMPLES_16K (2*FREEDV_NSAMPLES) +#define START_LOG_FRAMES 100 +#define LOG_FRAMES 10 +#define STOP_LOG_FRAMES (START_LOG_FRAMES+LOG_FRAMES) +#define NC 16 + +int main(void) { + struct freedv *f; + short adc16k[FDMDV_OS_TAPS_16K+FREEDV_NSAMPLES_16K]; + short dac16k[FREEDV_NSAMPLES_16K]; + short adc8k[FREEDV_NSAMPLES]; + short dac8k[FDMDV_OS_TAPS_8K+FREEDV_NSAMPLES]; + + int nin, nout, i, j, frames, lines; + + COMP *symb, *psymb; + + /* init all the drivers for various peripherals */ + + sm1000_leds_switches_init(); + dac_open(4*DAC_BUF_SZ); + adc_open(4*ADC_BUF_SZ); + f = freedv_open(FREEDV_MODE_1600); + + /* clear filter memories */ + + for(i=0; itotal_bit_errors = 0; + + if (adc1_read(&adc16k[FDMDV_OS_TAPS_16K], 2*nin) == 0) { + GPIOE->ODR = (1 << 3); + fdmdv_16_to_8_short(adc8k, &adc16k[FDMDV_OS_TAPS_16K], nin); + nout = freedv_rx(f, &dac8k[FDMDV_OS_TAPS_8K], adc8k); + fdmdv_8_to_16_short(dac16k, &dac8k[FDMDV_OS_TAPS_8K], nout); + dac2_write(dac16k, 2*nout); + led_ptt(0); led_rt(f->fdmdv_stats.sync); led_err(f->total_bit_errors); + GPIOE->ODR &= ~(1 << 3); + +#define TMP1 +#ifdef TMP1 + if (f->fdmdv_stats.sync) + frames++; + if ((frames >= START_LOG_FRAMES) && (lines < LOG_FRAMES)) { + for(i=0; i<=f->fdmdv_stats.Nc; i++) + psymb[i] = f->fdmdv_stats.rx_symbols[i]; + psymb += (f->fdmdv_stats.Nc+1); + lines++; + } + + if (frames >= STOP_LOG_FRAMES) { + FILE *ft = fopen("scatter.txt", "wt"); + assert(ft != NULL); + printf("Writing scatter file....\n"); + for(j=0; jfdmdv_stats.Nc; i++) { + fprintf(ft, "%f\t%f\t", + (double)symb[j*(f->fdmdv_stats.Nc+1)+i].real, + (double)symb[j*(f->fdmdv_stats.Nc+1)+i].imag); + printf("line: %d\n", j); + } + fprintf(ft, "\n"); + } + fclose(ft); + printf("SNR = %3.2f dB\nfinished!\n", (double)f->fdmdv_stats.snr_est); + while(1); + } +#endif + } + + } /* while(1) ... */ +} +