5.5.11 IIRCanonic

Description

IIRCanonic applies an IIR filter, using a cascade of canonic (direct form II) biquadratic sections, to the sequence of the source samples. It places the results in the sequence of the destination samples and updates the delay values.

Prototype

 typedef struct { 
  int numSectionsLess1; 
  fractional* coeffsBase; 
  fractional* delayBase; 
  int initialGain; 
  int finalShift; 
} IIRCanonicStruct; 

fractional* IIRCanonic (int numSamps, fractional* dstSamps, fractional* srcSamps, IIRCanonicStruct* filter);

Arguments

Filter Structure:

ParametersDescription

numSectionsLess1

One less than the number of cascaded second order (biquadratic) sections (also S-1)

coeffsBase

Pointer to filter coefficients (also {a, b}), either within X-Data or program memory

delayBase

Pointer to filter delay (also d), only in Y-Data

initialGain

Initial gain value

finalShift

Output scaling (shift left)

Filter Description:

ParametersDescription

numSamps

The number of input samples to filter (also N; with N being multiple of R)

dstSamps

Pointer to the destination samples (also y)

srcSamps

Pointer to the source samples (also x)

filter

Pointer to the IIRCanonicStruct filter structure

Return

Pointer to the base address of the destination sample.

Remarks

There are five coefficients per second order (biquadratic) sections (generated externally) arranged in the ordered set - {a2[s], a1[s], a0[s], b1[s], b0[s]}, 0 ≤ s < S.

The delay is made up of two words of filter state per section {d1[s], d2[s]}, 0 ≤ s < S.

Source samples, x[n], defined in 0 ≤ n < N.

Destination samples, y[n], defined in 0 ≤ n < N.

The initial gain value is applied to each input sample prior to entering the filter structure.

The output scale is applied as a shift to the output of the filter structure prior to storing the result in the output sequence. It is used to restore the filter gain to 0 dB. Shift count may be zero; if not zero, it represents the number of bits to shift: negative indicates shift left, positive is shift right. 

Source File

  • iircan_aa.s

Function Profile

DeviceProgram WordsCycles

PIC32A

30

See Cycle counts for PIC32A

Cycle counts for PIC32A:

Source Vector SizeCycles if coefficients in X-memCycles if coefficients in P-mem

32

1920

3538

64

3818

7026

128

7594

14002

256

15146

27954

512

30250

55858

1024

60458

111666

2048

120874

223282

(*All values with S = 5)

System resource usage

  • W0…W7 - used, not restored
  • W8…W9 - saved, used, restored
  • ACCA - used, not restored
  • CORCON - saved, used, restored
  • REPEAT instruction(s) usage – None