English
Language : 

RM0020 Datasheet, PDF (44/69 Pages) STMicroelectronics – SPC56xx DSP function library 2
Function API
RM0020
Algorithm:
ntaps – 1
 Equation 36 yn =
hk  xn – k for each n from 0 to N-1
k=0
Note: The filter coefficients must be stored in reversed order.
Performance: See Section 7 and Table 53.
Example 22. fir_float
#include "libdsp2.h"
/* #pragma and ALIGN macros used to align to 8 bytes */
#ifdef __ghs__
#pragma alignvar (8)
#endif
ALIGN_DCC(8)
float x[288/*+2*/] ALIGN_MWERKS(8); /* +2 to ensure there are 8
bytes of readable memory behind x */
#ifdef __ghs__
#pragma alignvar (8)
#endif
ALIGN_DCC(8)
float y [256] ALIGN_MWERKS(8);
#ifdef __ghs__
#pragma alignvar (8)
#endif
ALIGN_DCC(8)
float hr[33/*+2*/] ALIGN_MWERKS(8) = { /* +2 to ensure there are 8
bytes of readable memory behind hr */
-0.0015288448F,-0.0019041377F,-0.0025120102F,-0.0031517229F,-
0.0033815748F,-
0.0025689987F,0.0000000000F,0.0049703708F,0.0127558533F,0.023399631
1F,0.0364901802F,0.0511553726F,0.0661431077F,0.0799794722F,0.091179
2726F,0.0984722196F,0.1010036179F,0.0984722196F,0.0911792726F,0.079
9794722F,0.0661431077F,0.0511553726F,0.0364901802F,0.0233996311F,0.
0127558533F,0.0049703708F,0.0000000000F,-0.0025689987F,-
0.0033815748F,-0.0031517229F,-0.0025120102F,-0.0019041377F,-
0.0015288448F,
};
unsigned short N, ntaps;
void main(void)
{
/* filter the samples in x with FIR filter of 32nd order, */
/* write result into y, hr are filter coefficients stored */
/* in reversed order */
N = 256;
44/69