5.5.8 FIRLMS

Description

FIRLMS applies an adaptive FIR filter to the sequence of 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 Least Mean Square algorithm applied according to the values of the reference samples.

Prototype

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

Arguments

Parameters

Description

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)

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, placed in Y-data space.

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] + mu * (r[n] - y[n]) * x[n - m] for 0 ≤ n < N, 0 ≤ m < M.

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

Filter coefficients must not be allocated in the 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

Cycle counts for PIC32A:

Source Vector SizeCycles if coefficients in X-mem

32

5586

64

11098

128

22102

256

44122

512

88150

1024

176218

2048

352342

(*All values with numCoeffs = 32)

System resource usage

  • W0…W7 - used, not restored
  • W8…W12 - 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 – 1