/***************************************************************** * fir_fixpt_ccs.c - C program for FIR filtering using CCS * in Section 6.6.4 ****************************************************************** * 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" 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]; /***************************************************************** * Start of main program *****************************************************************/ while(TRUE) { /* read in x(n) from data file and processing it */ dataIO(); firproc(input, output); } } /* firproc - FIR filtering operations */ 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; 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++) { yn += (((long)(int)xnbuf[j] * (long)(int16_T)NUM[j])>>15); } *output++ = (int)(yn); } return(TRUE); } /* Function for dataIO */ static void dataIO() { return; }