1.4.2.9 DSP_FilterFIRDecim32 Function

Performs a decimating FIR filter on the input array.

Description

void DSP_FilterFIRDecim32(int32_t *outdata, int32_t *indata, int32_t *coeffs, int32_t *delayline, int N, int K, int scale, int rate);

Compute a FIR decimation filter on the input vector indata, and store the results to the vector outdata. The total number of output elements is set by N, and therefore the outdata array must be at least N in length. The decimation ratio is given by rate. The input is sampled every integer value of rate, skipping every (rate-1) input samples. The input array must therefore be (rate*N) samples long. The amount of filter taps is specified by K. Coeffs specifies the coefficients array. The delayline array holds delay inputs for calculation, and must be initialized to zero prior to calling the filter. Both coeffs and delayline must be K in length. Scale divides the input by a scaling factor by right shifting the number of bits (1/2^scale). All values of input, output, and coeffs are given in Q31 fractional data format. The function will saturate if the output value exceeds the maximum or minimum value.

Y = b0 * X0 + (b1 * X(-1)) + (b2 * X(-2)

Preconditions

The pointers outdata and indata must be aligned on 4-byte boundaries. delayline must have K elements, and be initialized to zero.

coeffs must have K elements. outdata must have N elements indata must have (N*rate) elements

Parameters

outdata pointer to output array of elements (int32_t)

indata pointer to input array of elements (int32_t)

coeffs pointer to an array of coefficients (int32_t)

delayline pointer to an array of delay variables (int32_t)

N number of output elements to be processed (int)

K number of filter taps and coeffs (int)

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

rate decimation ratio (int)

Returns

None.

Remarks

Coefs are loaded into the array with corresponding to the least delay first (C0, C(-1), C(-2)). K must be greater than rate. Even while decimating the input stream, every input passes through the delayline. So FIR filters of arbitrary length will give the same output as a non-decimating FIR, just with fewer responses.

Example

#define N 8 _// number of output samples_

#define TAPS 5

#define SKIP 3

int testFilterN = N; _// number of output elements_

int testFilterK = TAPS; _// number of taps_

int testFilterRate = SKIP; _// decimation rate R_

int32_t outFiltDataDec[N]={0};

int32_t *inTestFilter[N*SKIP];

int filtScaleNum = 1; _// scale output (1 /2\^n) => Y * 0.5_

int32_t filtDelayTest[8]={0}; _// always initialize to zero_

_// get pointer to input buffer here //_

inTestFilter = &inputBuffer;

DSP_FilterFIRDecim32(outFiltDataDec, inTestFilter, inTestCoefs,

filtDelayTest, testFilterN, testFilterK, filtScaleNum, testFilterRate);

C

void  DSP_FilterFIRDecim32 (int32_t * outdata , int32_t * indata , int32_t * coeffs , int32_t * delayline , int  N , int  K , int  scale , int  rate );