|
32 | 32 | @ingroup groupFilters
|
33 | 33 | */
|
34 | 34 |
|
35 |
| -/** |
36 |
| - @defgroup FIR_decimate Finite Impulse Response (FIR) Decimator |
37 |
| -
|
38 |
| - These functions combine an FIR filter together with a decimator. |
39 |
| - They are used in multirate systems for reducing the sample rate of a signal without introducing aliasing distortion. |
40 |
| - Conceptually, the functions are equivalent to the block diagram below: |
41 |
| - \image html FIRDecimator.gif "Components included in the FIR Decimator functions" |
42 |
| - When decimating by a factor of <code>M</code>, the signal should be prefiltered by a lowpass filter with a normalized |
43 |
| - cutoff frequency of <code>1/M</code> in order to prevent aliasing distortion. |
44 |
| - The user of the function is responsible for providing the filter coefficients. |
45 |
| -
|
46 |
| - The FIR decimator functions provided in the CMSIS DSP Library combine the FIR filter and the decimator in an efficient manner. |
47 |
| - Instead of calculating all of the FIR filter outputs and discarding <code>M-1</code> out of every <code>M</code>, only the |
48 |
| - samples output by the decimator are computed. |
49 |
| - The functions operate on blocks of input and output data. |
50 |
| - <code>pSrc</code> points to an array of <code>blockSize</code> input values and |
51 |
| - <code>pDst</code> points to an array of <code>blockSize/M</code> output values. |
52 |
| - In order to have an integer number of output samples <code>blockSize</code> |
53 |
| - must always be a multiple of the decimation factor <code>M</code>. |
54 |
| -
|
55 |
| - The library provides separate functions for Q15, Q31 and floating-point data types. |
56 |
| -
|
57 |
| - @par Algorithm: |
58 |
| - The FIR portion of the algorithm uses the standard form filter: |
59 |
| - <pre> |
60 |
| - y[n] = b[0] * x[n] + b[1] * x[n-1] + b[2] * x[n-2] + ...+ b[numTaps-1] * x[n-numTaps+1] |
61 |
| - </pre> |
62 |
| - where, <code>b[n]</code> are the filter coefficients. |
63 |
| - @par |
64 |
| - The <code>pCoeffs</code> points to a coefficient array of size <code>numTaps</code>. |
65 |
| - Coefficients are stored in time reversed order. |
66 |
| - @par |
67 |
| - <pre> |
68 |
| - {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]} |
69 |
| - </pre> |
70 |
| - @par |
71 |
| - <code>pState</code> points to a state array of size <code>numTaps + blockSize - 1</code>. |
72 |
| - Samples in the state buffer are stored in the order: |
73 |
| - @par |
74 |
| - <pre> |
75 |
| - {x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[0], x[1], ..., x[blockSize-1]} |
76 |
| - </pre> |
77 |
| - The state variables are updated after each block of data is processed, the coefficients are untouched. |
78 |
| -
|
79 |
| - @par Instance Structure |
80 |
| - The coefficients and state variables for a filter are stored together in an instance data structure. |
81 |
| - A separate instance structure must be defined for each filter. |
82 |
| - Coefficient arrays may be shared among several instances while state variable array should be allocated separately. |
83 |
| - There are separate instance structure declarations for each of the 3 supported data types. |
84 |
| -
|
85 |
| - @par Initialization Functions |
86 |
| - There is also an associated initialization function for each data type. |
87 |
| - The initialization function performs the following operations: |
88 |
| - - Sets the values of the internal structure fields. |
89 |
| - - Zeros out the values in the state buffer. |
90 |
| - - Checks to make sure that the size of the input is a multiple of the decimation factor. |
91 |
| - To do this manually without calling the init function, assign the follow subfields of the instance structure: |
92 |
| - numTaps, pCoeffs, M (decimation factor), pState. Also set all of the values in pState to zero. |
93 |
| - @par |
94 |
| - Use of the initialization function is optional. |
95 |
| - However, if the initialization function is used, then the instance structure cannot be placed into a const data section. |
96 |
| - To place an instance structure into a const data section, the instance structure must be manually initialized. |
97 |
| - The code below statically initializes each of the 3 different data type filter instance structures |
98 |
| - <pre> |
99 |
| - arm_fir_decimate_instance_f64 S = {M, numTaps, pCoeffs, pState}; |
100 |
| - arm_fir_decimate_instance_q31 S = {M, numTaps, pCoeffs, pState}; |
101 |
| - arm_fir_decimate_instance_q15 S = {M, numTaps, pCoeffs, pState}; |
102 |
| - </pre> |
103 |
| - where <code>M</code> is the decimation factor; <code>numTaps</code> is the number of filter coefficients in the filter; |
104 |
| - <code>pCoeffs</code> is the address of the coefficient buffer; |
105 |
| - <code>pState</code> is the address of the state buffer. |
106 |
| - Be sure to set the values in the state buffer to zeros when doing static initialization. |
107 |
| -
|
108 |
| - @par Fixed-Point Behavior |
109 |
| - Care must be taken when using the fixed-point versions of the FIR decimate filter functions. |
110 |
| - In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. |
111 |
| - Refer to the function specific documentation below for usage guidelines. |
112 |
| - */ |
113 |
| - |
114 | 35 | /**
|
115 | 36 | @addtogroup FIR_decimate
|
116 | 37 | @{
|
@@ -168,10 +89,10 @@ void arm_fir_decimate_f64(
|
168 | 89 | } while (--i);
|
169 | 90 |
|
170 | 91 | /* Set accumulators to zero */
|
171 |
| - acc0 = 0.0f; |
172 |
| - acc1 = 0.0f; |
173 |
| - acc2 = 0.0f; |
174 |
| - acc3 = 0.0f; |
| 92 | + acc0 = 0.0; |
| 93 | + acc1 = 0.0; |
| 94 | + acc2 = 0.0; |
| 95 | + acc3 = 0.0; |
175 | 96 |
|
176 | 97 | /* Initialize state pointer for all the samples */
|
177 | 98 | px0 = pState;
|
@@ -314,7 +235,7 @@ void arm_fir_decimate_f64(
|
314 | 235 | } while (--i);
|
315 | 236 |
|
316 | 237 | /* Set accumulator to zero */
|
317 |
| - acc0 = 0.0f; |
| 238 | + acc0 = 0.0; |
318 | 239 |
|
319 | 240 | /* Initialize state pointer */
|
320 | 241 | px0 = pState;
|
|
0 commit comments