03.08.2013 Views

Embedded Software and Motor Control Libraries for PXR40xx

Embedded Software and Motor Control Libraries for PXR40xx

Embedded Software and Motor Control Libraries for PXR40xx

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Equation GDFLIB_FilterFIR_Eq1<br />

where: x[n] is the input signal, y[n] is the output signal, h i are the filter coefficients, <strong>and</strong><br />

N is the filter order. It should be noted, that the number of taps of the filter is N + 1 in<br />

this case.<br />

The function assumes that the filter order is at least one, which is equivalent to two taps.<br />

The filter also cannot contain more than 0xffffffff(hexadecimal) taps, which is equivalent<br />

to the order of 0xfffffffe (hexadecimal).<br />

The input values are recorded by the function in the provided state structure in a circular<br />

buffer, pointed to by the state structure member pState->pInBuf. The buffer index is<br />

stored in pState->u32Idx, which points to the buffer element where a new input signal<br />

sample will be stored.<br />

The filter coefficients are stored in the parameter structure, in the structure member<br />

pParam->pCoefBuf.<br />

The first call to the function must be preceded by an initialization, which can be made<br />

through the GDFLIB_FilterFIRInit_FLT function. The GDFLIB_FilterFIRInit_FLT <strong>and</strong><br />

then the GDFLIB_FilterFIR_FLT functions should be called with the same parameters.<br />

4.6.5 Re-entrancy<br />

The function is re-entrant only if the calling code is provided with a distinct instance of<br />

the structure pointed to by pState.<br />

Note<br />

From the per<strong>for</strong>mance point of view, the function is designed to<br />

work with filters with a larger number of taps (equal order + 1).<br />

As a rule of thumb, if the number of taps is lower than 5, a<br />

different algorithm should be considered.<br />

4.6.6 Code Example<br />

#include "gdflib.h"<br />

#define FIR_NUMTAPS 16<br />

#define FIR_NUMTAPS_MAX 64<br />

#define FIR_ORDER (FIR_NUMTAPS - 1)<br />

<strong>Embedded</strong> <strong>Software</strong> <strong>and</strong> <strong>Motor</strong> <strong>Control</strong> <strong>Libraries</strong> <strong>for</strong> <strong>PXR40xx</strong>, Rev. 1.0<br />

Chapter 4 API References<br />

Freescale Semiconductor, Inc. 165

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!