From: drowe67 Date: Sun, 31 Aug 2014 05:08:35 +0000 (+0000) Subject: UT to measure rms noise on ADC ports X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=bb74a4fdb9437abe7ed88e6d1b9ac94e96d0c40a;p=freetel-svn-tracking.git UT to measure rms noise on ADC ports git-svn-id: https://svn.code.sf.net/p/freetel/code@1823 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/stm32/src/adc_sd.c b/codec2-dev/stm32/src/adc_sd.c new file mode 100644 index 00000000..91414d2c --- /dev/null +++ b/codec2-dev/stm32/src/adc_sd.c @@ -0,0 +1,75 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: adc_sd.c + AUTHOR......: David Rowe + DATE CREATED: 30 May 2014 + + Measures the std deviation of the ADC signals. Used to check noise + levels on each ADC. + +\*---------------------------------------------------------------------------*/ + +/* + 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 "stm32f4_adc.h" +#include "stm32f4_dac.h" +#include "gdb_stdio.h" + +#define REC_TIME_SECS 10 +#define N (ADC_BUF_SZ*4) +#define FS 16000 + +static float calc_sd(short x[], int n) { + float sum, mean, sum_diff, sd; + int i; + + sum = 0.0; + for(i=0; i