1.4.2.8 DSP_FilterFIR32 Function

Performs a Finite Infinite Response (FIR) filter on a vector.

Description

void DSP_FilterFIR32(int32_t *outdata, int32_t *indata, int32_t *coeffs2x, int32_t *delayline, int N, int K, int scale);

Performs an FIR filter on the vector indata, and stores the output in the vector outdata. The number of samples processed in the array is given by N. The number of filter taps is given by K. The values are scaled upon input by the binary scaling factor (right shift), scale. The array of 2*K coefficients is contained in the array coeffs2x, where the values are in order b0, b1, b2... and repeated. Lastly the delayline is an array of K values that are initialized to zero and represent previous values. All values are in fractional Q31 data format. The function will saturate results if minimum or maximum values are exceeded.

Preconditions

The pointers outdata and indata must be aligned on 4-byte boundaries. N must be greater than or equal to four and a multiple of four. K must be greater than 2 and a multiple of 2. delayline must have K elements, and be initialized to zero. coeffs2x must have 2*K elements.

Parameters

outdata pointer to destination array of elements (int32_t)

indata pointer to source array of elements (int32_t)

coeffs2x pointer to an array of coefficients (int32_t)

delayline pointer to an array of delay variables (int32_t)

N number of points in the array to process (int) number of samples (int)

K number of filter taps

scale binary scaler divisor (1 / 2^scale) (int)

Returns

None.

Remarks

Filter coefs must be repeated within the array. The array is twice as large as the number of taps, and the values are repeated in order b0, b1, b2,...bn, b0, b1, b2,... bn. The function updates the delayline array, which must be K elements long. The array should be initialized to zero prior to the first processing. It will contain values for processing cascaded filters within a loop.

Example

#define TAPS 4

#define numPOINTS 256

int filterN = numPOINTS;

int filterK = TAPS;

int filterScale = 1; _// scale output by 1/2\^1 => output * 0.5_

int32_t FilterCoefs[TAPS*2] = {0x40000000, 0x20000000, 0x20000000, 0x20000000,

0x40000000, 0x20000000, 0x20000000, 0x20000000};

_// note repeated filter coefs, A B C D A B C D_

_// 0.5, 0.25, 0.25, 0.25, 0.5, 0.25, 0.25, 0.25_

int32_t outFilterData[numPOINTS]={0};

int32_t inFilterData[numPOINTS];

int filterDelayLine[TAPS]={0};

while ( true )

{

_// put some data into input array, inFilterData, here //_

DSP_FilterFIR32(outFilterData, inFilterData, FilterCoefs, filterDelayLine,

filterN, filterK, filterScale);

}

C

void  DSP_FilterFIR32 (int32_t * outdata , int32_t * indata , int32_t * coeffs2x , int32_t * delayline , int  N , int  K , int  scale );