From: drowe67 Date: Wed, 22 May 2013 23:26:56 +0000 (+0000) Subject: added GPIO based execution speed test to check profiling results, simailr results... X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=56c702df59d21fff96a17abe0769d129c8d66862;p=freetel-svn-tracking.git added GPIO based execution speed test to check profiling results, simailr results, abt 36ms out of 40 git-svn-id: https://svn.code.sf.net/p/freetel/code@1263 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/stm32/Makefile b/codec2-dev/stm32/Makefile index 3946dc5f..b4efc996 100644 --- a/codec2-dev/stm32/Makefile +++ b/codec2-dev/stm32/Makefile @@ -110,7 +110,7 @@ OBJS = $(SRCS:.c=.o) ################################################### -all: libstm32f4.a $(PROJ_NAME).elf fft_test.elf +all: libstm32f4.a $(PROJ_NAME).elf fft_test.elf dactest.elf dl/$(PERIPHLIBZIP): mkdir -p dl @@ -132,6 +132,18 @@ $(PROJ_NAME).elf: $(SRCS) fft_test.elf: $(FFT_TEST_SRCS) $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) +DAC_TEST=$(PERIPHLIBDIR)/Project/STM32F4xx_StdPeriph_Examples/DAC/DAC_SignalsGeneration +DAC_TEST_SRCS=\ +$(DAC_TEST)/main.c \ +$(DAC_TEST)/stm32f4xx_it.c \ +$(DAC_TEST)/system_stm32f4xx.c \ +$(PERIPHLIBDIR)/Utilities/STM32_EVAL/STM3240_41_G_EVAL/stm324xg_eval.c \ +src/startup_stm32f4xx.s \ +src/init.c + +dactest.elf: $(DAC_TEST_SRCS) + $(CC) $(CFLAGS) -DUSE_STM324xG_EVAL -I$(PERIPHLIBDIR)/Utilities/STM32_EVAL/STM3240_41_G_EVAL -I$(PERIPHLIBDIR)/Utilities/STM32_EVAL/Common $^ -o $@ $(LIBPATHS) $(LIBS) + clean: rm -f *.o rm -f *.elf diff --git a/codec2-dev/stm32/README.txt b/codec2-dev/stm32/README.txt index eac2d04b..d4d7d557 100644 --- a/codec2-dev/stm32/README.txt +++ b/codec2-dev/stm32/README.txt @@ -30,14 +30,14 @@ Getting Started $ cd stlink ~/stlink$ git checkout bbecbc1e81b15b85829149424d048d96bd844939 ~/stlink$ patch -p0 < ~/codec2-dev/stm32/stlink/stlink.patch - ~/stlink$ cp ~/codec2-dev/stm32/stlink/elfsym.* . + ~/stlink$ cp ~/codec2-dev/stm32/stlink/elfsym.* gdbserver ~/stlink$ ./autogen.sh ~/stlink$ ./configure ~/stlink$ make . Place a copy of hts1a.raw in the stlink directory and start st-util: - ~/stlink$ cp ~/codec2-dev/raw/hts1a . + ~/stlink$ cp ~/codec2-dev/raw/hts1a.raw . ~/stlink$ sudo ./st-util -f /home/david/codec2-dev/stm32/stm32f4_codec2.elf . In _another_ console start gdb: diff --git a/codec2-dev/stm32/src/init.c b/codec2-dev/stm32/src/init.c new file mode 100644 index 00000000..a724e407 --- /dev/null +++ b/codec2-dev/stm32/src/init.c @@ -0,0 +1,7 @@ +/* + * Dummy function to avoid compiler error + */ +void _init() { + +} + diff --git a/codec2-dev/stm32/src/main.c b/codec2-dev/stm32/src/main.c index 7b8622d1..5b538f2e 100644 --- a/codec2-dev/stm32/src/main.c +++ b/codec2-dev/stm32/src/main.c @@ -55,7 +55,7 @@ static void c2demo(int mode, char inputfile[], char outputfile[]) while (fread(inbuf, sizeof(short), nsam, fin) == nsam) { enc_start = machdep_timer_sample(); - codec2_encode(codec2, bits, inbuf); + codec2_encode(codec2, bits, inbuf); dec_start = machdep_timer_sample_and_log(enc_start, " enc"); codec2_decode(codec2, outbuf, bits); machdep_timer_sample_and_log(dec_start, " dec"); @@ -76,12 +76,78 @@ static void c2demo(int mode, char inputfile[], char outputfile[]) codec2_destroy(codec2); } +#define SPEED_TEST_SAMPLES 24000 + +static void c2speedtest(int mode, char inputfile[]) +{ + struct CODEC2 *codec2; + short *inbuf, *outbuf, *pinbuf; + unsigned char *bits; + int nsam, nbit, nframes; + FILE *fin; + int f, nread; + + codec2 = codec2_create(mode); + nsam = codec2_samples_per_frame(codec2); + nframes = SPEED_TEST_SAMPLES/nsam; + outbuf = (short*)malloc(nsam*sizeof(short)); + inbuf = (short*)malloc(SPEED_TEST_SAMPLES*sizeof(short)); + nbit = codec2_bits_per_frame(codec2); + bits = (unsigned char*)malloc(nbit*sizeof(char)); + + fin = fopen(inputfile, "rb"); + if (fin == NULL) { + printf("Error opening input file: %s\n",inputfile); + exit(1); + } + + nread = fread(inbuf, sizeof(short), SPEED_TEST_SAMPLES, fin); + if (nread != SPEED_TEST_SAMPLES) { + printf("error reading %s, %d samples reqd, %d read\n", + inputfile, SPEED_TEST_SAMPLES, nread); + } + fclose(fin); + + pinbuf = inbuf; + for(f=0; fODR = (1 << 13); + codec2_encode(codec2, bits, pinbuf); + pinbuf += nsam; + GPIOD->ODR &= ~(1 << 13); + codec2_decode(codec2, outbuf, bits); + } + + free(inbuf); + free(outbuf); + free(bits); + codec2_destroy(codec2); +} + +void gpio_init() { + RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN; // enable the clock to GPIOD + GPIOD->MODER = (1 << 26); // set pin 13 to be general + // purpose output +} + int main(void) { SystemInit(); - printf("Starting\n"); + gpio_init(); machdep_timer_init (); + + printf("Starting c2demo\n"); + + /* File I/O test for profiling or (with #define DUMP) + dumping states for optimisation and tiuning */ c2demo(CODEC2_MODE_1600, "hts1a.raw", "hts1a_out.raw"); + + printf("Starting c2 speed test\n"); + + /* Another test of execution speed. Look at PD13 with a + oscilliscope. On time is enc, off is dec */ + + c2speedtest(CODEC2_MODE_1600, "hts1a.raw"); + printf("Finished\n"); return 0;