5.5.9 FIRLMSNorm

Description

FIRLMSNorm applies an adaptive FIR filter to the sequence of the source samples, stores the results in the sequence of destination samples and updates the delay values.

The filter coefficients are also updated, at a sample-per-sample basis, using a Normalized Least Mean Square algorithm applied according to the values of the reference samples.

Prototype

fractional* FIRLMSNorm (int numSamps, fractional* dstSamps, fractional* srcSamps, FIRStruct* filter, fractional* refSamps, fractional muVal, fractional* energyEstimate);

Arguments

ParametersDescription

numSamps

Number of the 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 FIRStruct filter structure

refSamps

Pointer to the reference samples (also r)

muVal

Adapting factor (also mu)

energyEstimate

Pointer to the estimated energy (e[N-1]) value for the last M input samples

Return

Pointer to the base address of the destination sample.

Remarks

Number of the filter coefficients is M.

Coefficients, h[m], defined in 0 ≤ m < M, are implemented as a circular modulo buffer.

Delay, d[m], defined in 0 ≤ m < M, is implemented as a circular modulo buffer.

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

Reference samples, r[n], defined in 0 ≤ n < N.

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

Adaptation:

hm[n] = hm[n - 1] + nu * (r[n] - y[n]) * x[n - m] for 0 ≤ n < N, 0 ≤ m < M.

Where,

With,

E[n] = E[n - 1] + (x[n])2 - (x[n - M - 1])2 an estimate of input signal energy.

On start-up, energyEstimate should be initialized to the value of E[-1] (zero the first time the filter is invoked). Upon return, energyEstimate is updated to the value E[N – 1] (which may be used as the start-up value for a subsequent function call, if filtering an extension of the input signal).

The operation could result in saturation, if the absolute value of (r[n] – y[n]) is greater than or equal to 1.

Note: Another expression for the energy estimate is: E[n] = (x[n])2 + (x[n - 1])2 + … + (x[n - M + 2])2

Thus, to avoid saturation while computing the estimate, the input sample values should be bound so that:

Filter coefficients must not be allocated in program memory, because in that case, their values could not be adapted. If filter coefficients are detected as allocated in program memory, the function returns NULL.

(See also FIRStructFIRStructInit and FIRInterpDelayInit.)

Source File

  • firlms_aa.s

Function Profile

DeviceProgram WordsCycles

PIC32A

74

See Cycle counts for PIC32A

Cycle counts for PIC32A:

Source Vector SizeCycles if coefficients in X-mem

32

6360

64

12636

128

25176

256

50268

512

100440

1024

200796

2048

401496

(*All values with numCoeffs = 32)

System resource usage

  • W0…W7 - used, not restored
  • W8…W13 - saved, used, restored
  • ACCA - used, not restored
  • CORCON - saved, used, restored
  • MODCON - saved, used, restored
  • XMODSTRT - saved, used, restored
  • XMODEND - saved, used, restored
  • YMODSTRT - saved, used, restored
  • YMODEND - saved, used, restored
  • REPEAT instruction(s) usage – 2