arm signal converge example f32 8c source


CMSIS DSP Software Library: arm_signal_converge_example_f32.c Source File Main Page Modules Data Structures Files Examples File List Globals arm_signal_converge_example_f32.c Go to the documentation of this file.00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2010 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 29. November 2010 00005 * $Revision: V1.0.3 00006 * 00007 * Project: CMSIS DSP Library 00008 * Title: arm_signal_converge_example_f32.c 00009 * 00010 * Description: Example code demonstrating convergence of an adaptive 00011 * filter. 00012 * 00013 * Target Processor: Cortex-M4/Cortex-M3 00014 * 00015 * 00016 * Version 1.0.3 2010/11/29 00017 * Re-organized the CMSIS folders and updated documentation. 00018 * 00019 * Version 1.0.1 2010/10/05 KK 00020 * Production release and review comments incorporated. 00021 * 00022 * Version 1.0.0 2010/09/20 KK 00023 * Production release and review comments incorporated. 00024 * ------------------------------------------------------------------- */ 00025 00093 #include "arm_math.h" 00094 #include "math_helper.h" 00095 00096 /* ---------------------------------------------------------------------- 00097 ** Global defines for the simulation 00098 * ------------------------------------------------------------------- */ 00099 00100 #define TEST_LENGTH_SAMPLES 1536 00101 #define NUMTAPS 32 00102 #define BLOCKSIZE 32 00103 #define DELTA_ERROR 0.000001f 00104 #define DELTA_COEFF 0.0001f 00105 #define MU 0.5f 00106 00107 #define NUMFRAMES (TEST_LENGTH_SAMPLES / BLOCKSIZE) 00108 00109 /* ---------------------------------------------------------------------- 00110 * Declare FIR state buffers and structure 00111 * ------------------------------------------------------------------- */ 00112 00113 float32_t firStateF32[NUMTAPS + BLOCKSIZE]; 00114 arm_fir_instance_f32 LPF_instance; 00115 00116 /* ---------------------------------------------------------------------- 00117 * Declare LMSNorm state buffers and structure 00118 * ------------------------------------------------------------------- */ 00119 00120 float32_t lmsStateF32[NUMTAPS + BLOCKSIZE]; 00121 float32_t errOutput[TEST_LENGTH_SAMPLES]; 00122 arm_lms_norm_instance_f32 lmsNorm_instance; 00123 00124 00125 /* ---------------------------------------------------------------------- 00126 * Function Declarations for Signal Convergence Example 00127 * ------------------------------------------------------------------- */ 00128 00129 arm_status test_signal_converge_example( void ); 00130 00131 00132 /* ---------------------------------------------------------------------- 00133 * Internal functions 00134 * ------------------------------------------------------------------- */ 00135 arm_status test_signal_converge(float32_t* err_signal, 00136 uint32_t blockSize); 00137 00138 void getinput(float32_t* input, 00139 uint32_t fr_cnt, 00140 uint32_t blockSize); 00141 00142 /* ---------------------------------------------------------------------- 00143 * External Declarations for FIR F32 module Test 00144 * ------------------------------------------------------------------- */ 00145 extern float32_t testInput_f32[TEST_LENGTH_SAMPLES]; 00146 extern float32_t lmsNormCoeff_f32[32]; 00147 extern const float32_t FIRCoeff_f32[32]; 00148 extern arm_lms_norm_instance_f32 lmsNorm_instance; 00149 00150 /* ---------------------------------------------------------------------- 00151 * Declare I/O buffers 00152 * ------------------------------------------------------------------- */ 00153 00154 float32_t wire1[BLOCKSIZE]; 00155 float32_t wire2[BLOCKSIZE]; 00156 float32_t wire3[BLOCKSIZE]; 00157 float32_t err_signal[BLOCKSIZE]; 00158 00159 /* ---------------------------------------------------------------------- 00160 * Signal converge test 00161 * ------------------------------------------------------------------- */ 00162 00163 int32_t main(void) 00164 { 00165 uint32_t i; 00166 arm_status status; 00167 uint32_t index; 00168 float32_t minValue; 00169 00170 /* Initialize the LMSNorm data structure */ 00171 arm_lms_norm_init_f32(&lmsNorm_instance, NUMTAPS, lmsNormCoeff_f32, lmsStateF32, MU, BLOCKSIZE); 00172 00173 /* Initialize the FIR data structure */ 00174 arm_fir_init_f32(&LPF_instance, NUMTAPS, (float32_t *)FIRCoeff_f32, firStateF32, BLOCKSIZE); 00175 00176 /* ---------------------------------------------------------------------- 00177 * Loop over the frames of data and execute each of the processing 00178 * functions in the system. 00179 * ------------------------------------------------------------------- */ 00180 00181 for(i=0; i < NUMFRAMES; i++) 00182 { 00183 /* Read the input data - uniformly distributed random noise - into wire1 */ 00184 arm_copy_f32(testInput_f32 + (i * BLOCKSIZE), wire1, BLOCKSIZE); 00185 00186 /* Execute the FIR processing function. Input wire1 and output wire2 */ 00187 arm_fir_f32(&LPF_instance, wire1, wire2, BLOCKSIZE); 00188 00189 /* Execute the LMS Norm processing function*/ 00190 00191 arm_lms_norm_f32(&lmsNorm_instance, /* LMSNorm instance */ 00192 wire1, /* Input signal */ 00193 wire2, /* Reference Signal */ 00194 wire3, /* Converged Signal */ 00195 err_signal, /* Error Signal, this will become small as the signal converges */ 00196 BLOCKSIZE); /* BlockSize */ 00197 00198 /* apply overall gain */ 00199 arm_scale_f32(wire3, 5, wire3, BLOCKSIZE); /* in-place buffer */ 00200 } 00201 00202 status = ARM_MATH_SUCCESS; 00203 00204 /* ------------------------------------------------------------------------------- 00205 * Test whether the error signal has reached towards 0. 00206 * ----------------------------------------------------------------------------- */ 00207 00208 arm_abs_f32(err_signal, err_signal, BLOCKSIZE); 00209 arm_min_f32(err_signal, BLOCKSIZE, &minValue, &index); 00210 00211 if (minValue > DELTA_ERROR) 00212 { 00213 status = ARM_MATH_TEST_FAILURE; 00214 } 00215 00216 /* ---------------------------------------------------------------------- 00217 * Test whether the filter coefficients have converged. 00218 * ------------------------------------------------------------------- */ 00219 00220 arm_sub_f32((float32_t *)FIRCoeff_f32, lmsNormCoeff_f32, lmsNormCoeff_f32, NUMTAPS); 00221 00222 arm_abs_f32(lmsNormCoeff_f32, lmsNormCoeff_f32, NUMTAPS); 00223 arm_min_f32(lmsNormCoeff_f32, NUMTAPS, &minValue, &index); 00224 00225 if (minValue > DELTA_COEFF) 00226 { 00227 status = ARM_MATH_TEST_FAILURE; 00228 } 00229 00230 /* ---------------------------------------------------------------------- 00231 * Loop here if the signals did not pass the convergence check. 00232 * This denotes a test failure 00233 * ------------------------------------------------------------------- */ 00234 00235 if( status != ARM_MATH_SUCCESS) 00236 { 00237 while(1); 00238 } 00239 } 00240  All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines Generated on Mon Nov 29 2010 17:19:57 for CMSIS DSP Software Library by  1.7.2

Wyszukiwarka

Podobne podstrony:
arm signal converge example ?2?
arm linear interp example ?2? source
arm signal converge example?2? example
arm class marks example ?2? source
arm sin cos example ?2? source
arm sin cos example ?2? source
arm ?t bin example ?2? source
arm dotproduct example ?2? source
arm fir example ?2? source
arm convolution example ?2? source
arm variance example ?2? source
arm matrix example ?2? source
arm iir lattice init ?2? source
arm biquad ?scade ?1 ?2? source
arm cmplx mag squared ?2? source
arm ?ft radix4 init ?2? source
arm cmplx mult cmplx ?2? source
arm fir interpolate init ?2? source
arm ?t bin example ?2?

więcej podobnych podstron