1.4.2.11 DSP_FilterIIR16 Function

Performs a single-sample cascaded biquad Infinite Impulse Response (IIR) filter.

Description

int16_t DSP_FilterIIR16(int16_t in, int16_t *coeffs, int16_t *delayline, int B, int scale);

Performs a single element cascaded biquad IIR filter on the input, in. The filter contains B number of biquad sections, and cascades the output of one to the input of the next. B must be greater than 2 and a multiple of 2. The int16_t output generated by the function is the computation from the final biquad stage. Delay pipeline array delayline must contain 2B values and be initialized to zero prior to use. The coefficient array must contain 4B elements, and must be set up in order of biquad a1, a2, b1, b2. A binary (right shift) factor, scale, will scale the output equivalent to (1/2^scale). All numerical values must be in Q15 fractional data format. The function will saturate values if maximum or minimum values are exceeded.

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

Preconditions

The pointers outdata and indata must be aligned on 4-byte boundaries. B must be greater than 2 and a multiple of 2. delayline must have 2B elements, and be initialized to zero. coeffs must have 4B elements.

Parameters

in input data element X (int16_t)

coeffs pointer to an array of coefficients (int16_t)

delayline pointer to an array of delay variables (int16_t)

B number of cascaded biquad filter groups to process (int)

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

Returns

Sample output Y (int16_t)

Example

#define B 8 _// use * biquad filters in cascade_

int dataSamples = 256;

int i, j;

biquad16 bquad[B];

int16_t coefs[4*B]= {0};

int16_t delaylines[2*B]= {0};

int16_t Y, X;

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

_// do something to set up coefs, for instance this example //_

for (j=0; jRemarks:Filter coefs must be stored within the array as a1, a2, b1, b2, a1, a2, b1, b2, in order of biquads form input to output. A function to translate the coeffs from biquad structure to coeffs is available in DSP_FilterIIRSetup16. The function updates the delayline array, which must be 2*B 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.

C

int16_t DSP_FilterIIR16 (int16_t in , int16_t * coeffs , int16_t * delayline , int  B , int  scale );