CMSIS DSP Software Library: arm_linear_interp_example_f32.c Source File
Main Page
Modules
Data Structures
Files
Examples
File List
Globals
arm_linear_interp_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_linear_interp_example_f32.c
00009 *
00010 * Description: Example code demonstrating usage of sin function
00011 * and uses linear interpolation to get higher precision
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
00070 #include "arm_math.h"
00071 #include "math_helper.h"
00072
00073 #define SNR_THRESHOLD 90
00074 #define TEST_LENGTH_SAMPLES 10
00075 #define XSPACING (0.00005f)
00076
00077 /* ----------------------------------------------------------------------
00078 * Test input data for F32 SIN function
00079 * Generated by the MATLAB rand() function
00080 * randn('state', 0)
00081 * xi = (((1/4.18318581819710)* randn(blockSize, 1) * 2* pi));
00082 * --------------------------------------------------------------------*/
00083 float32_t testInputSin_f32[TEST_LENGTH_SAMPLES] =
00084 {
00085 -0.649716504673081170, -2.501723745497831200, 0.188250329003310100, 0.432092748487532540, -1.722010988459680800, 1.788766476323060600, 1.786136060975809500, -0.056525543169408797,
00086 0.491596272728153760, 0.262309671126153390
00087 };
00088
00089 /*------------------------------------------------------------------------------
00090 * Reference out of SIN F32 function for Block Size = 10
00091 * Calculated from sin(testInputSin_f32)
00092 *------------------------------------------------------------------------------*/
00093 float32_t testRefSinOutput32_f32[TEST_LENGTH_SAMPLES] =
00094 {
00095 -0.604960695383043530, -0.597090287967934840, 0.187140422442966500, 0.418772124875992690, -0.988588831792106880, 0.976338412038794010, 0.976903856413481100, -0.056495446835214236,
00096 0.472033731854734240, 0.259311907228582830
00097 };
00098
00099 /*------------------------------------------------------------------------------
00100 * Method 1: Test out Buffer Calculated from Cubic Interpolation
00101 *------------------------------------------------------------------------------*/
00102 float32_t testOutput[TEST_LENGTH_SAMPLES];
00103
00104 /*------------------------------------------------------------------------------
00105 * Method 2: Test out buffer Calculated from Linear Interpolation
00106 *------------------------------------------------------------------------------*/
00107 float32_t testLinIntOutput[TEST_LENGTH_SAMPLES];
00108
00109 /*------------------------------------------------------------------------------
00110 * External table used for linear interpolation
00111 *------------------------------------------------------------------------------*/
00112 extern float32_t arm_linear_interep_table[188495];
00113
00114 /* ----------------------------------------------------------------------
00115 * Global Variables for caluclating SNR's for Method1 & Method 2
00116 * ------------------------------------------------------------------- */
00117 float32_t snr1;
00118 float32_t snr2;
00119
00120 /* ----------------------------------------------------------------------------
00121 * Calculation of Sine values from Cubic Interpolation and Linear interpolation
00122 * ---------------------------------------------------------------------------- */
00123 int32_t main(void)
00124 {
00125 uint32_t i;
00126 arm_status status;
00127
00128 arm_linear_interp_instance_f32 S = {188495, -3.141592653589793238, XSPACING, &arm_linear_interep_table[0]};
00129
00130 /*------------------------------------------------------------------------------
00131 * Method 1: Test out Calculated from Cubic Interpolation
00132 *------------------------------------------------------------------------------*/
00133 for(i=0; i< TEST_LENGTH_SAMPLES; i++)
00134 {
00135 testOutput[i] = arm_sin_f32(testInputSin_f32[i]);
00136 }
00137
00138 /*------------------------------------------------------------------------------
00139 * Method 2: Test out Calculated from Cubic Interpolation and Linear interpolation
00140 *------------------------------------------------------------------------------*/
00141
00142 for(i=0; i< TEST_LENGTH_SAMPLES; i++)
00143 {
00144 testLinIntOutput[i] = arm_linear_interp_f32(&S, testInputSin_f32[i]);
00145 }
00146
00147 /*------------------------------------------------------------------------------
00148 * SNR calculation for method 1
00149 *------------------------------------------------------------------------------*/
00150 snr1 = arm_snr_f32(testRefSinOutput32_f32, testOutput, 2);
00151
00152 /*------------------------------------------------------------------------------
00153 * SNR calculation for method 2
00154 *------------------------------------------------------------------------------*/
00155 snr2 = arm_snr_f32(testRefSinOutput32_f32, testLinIntOutput, 2);
00156
00157 /*------------------------------------------------------------------------------
00158 * Initialise status depending on SNR calculations
00159 *------------------------------------------------------------------------------*/
00160 if( snr2 > snr1)
00161 {
00162 status = ARM_MATH_SUCCESS;
00163 }
00164 else
00165 {
00166 status = ARM_MATH_TEST_FAILURE;
00167 }
00168
00169 /* ----------------------------------------------------------------------
00170 ** Loop here if the signals fail the PASS check.
00171 ** This denotes a test failure
00172 ** ------------------------------------------------------------------- */
00173 if( status != ARM_MATH_SUCCESS)
00174 {
00175 while(1);
00176 }
00177 }
00178
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated on Mon Nov 29 2010 17:19:56 for CMSIS DSP Software Library by
1.7.2
Wyszukiwarka
Podobne podstrony:
arm linear interp example ?2?arm fir interpolate init ?2? sourcearm linear interp example?2? examplearm signal converge example ?2? sourcearm class marks example ?2? sourcearm sin cos example ?2? sourcearm sin cos example ?2? sourcearm ?t bin example ?2? sourcearm dotproduct example ?2? sourcearm fir example ?2? sourcearm convolution example ?2? sourcearm variance example ?2? sourcearm matrix example ?2? sourcearm iir lattice init ?2? sourcearm biquad ?scade ?1 ?2? sourcearm cmplx mag squared ?2? sourcearm ?ft radix4 init ?2? sourcearm cmplx mult cmplx ?2? sourcearm fir interpolate init q15? sourcewięcej podobnych podstron