/****************************************************************** * fir_fixpt_intr.c - C program for FIR filtering using intrinsics* * in Section 6.6.5 * ******************************************************************* * System configuration: * * * in(n) |----------------| out(n) * ---->| Bandpass filter|-----> * |----------------| * ****************************************************************** * System simulation configuration: * * in_buffer is used to store the input data * out_buffer is used to store the output filtered data * *****************************************************************/ #include #include #include #include "coeff_ccs_16int.h" #include int in_buffer[300]; int out_buffer[300]; #define TRUE 1 /*Function */ static int firproc(int *input, int *output); static void dataIO(void); void main() { /***************************************************************** * Declare file pointers *****************************************************************/ int *input = &in_buffer[0]; int *output= &out_buffer[0]; asm(" STM #0, SWWSR"); /***************************************************************** * Start of main program *****************************************************************/ while(TRUE) { /* read in x(n) from data file and processing it */ dataIO(); firproc(input, output); } } /* firproc - FIR filtering */ static int firproc(int *input, int *output) { /***************************************************************** * Define variable arrays, define and clear variables *****************************************************************/ long yn = 0; /* y(n), output from IIR filter */ int xnbuf[96]; int i,j,k; int size = 300; long temp = 0; for(k=0;k0;i--) { xnbuf[i]=xnbuf[i-1]; } xnbuf[0]=*input++; /************************************************************* * FIR filtering: * y(n) = Sum[x(n-i)*coeff(i)] for i = 0 to NL-1 *************************************************************/ yn = 0; for (j=0; j< NL; j++) { temp = _lsmpy(xnbuf[j],(int16_T)NUM[j])>>16; yn = _lsadd(yn,temp); /* yn += (_smac(temp,xnbuf[j],NUM[j])>>16); */ } *output++ = (int)(yn); } return(TRUE); } /* Function for dataIO */ static void dataIO() { return; }