/***************************************************************** * fir_fixpt_c55x.c - Fixed-point C for FIR filtering using CCS * * the FIR function is in C55x assembly * * in Section 6.6.6.2 * ****************************************************************** * 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" /* coefficient header file */ int in_buffer[300]; int out_buffer[300]; #define TRUE 1 /* Functions */ static int firproc(int *input, int *output); static void dataIO(void); extern int fir_c55(int *,int ,const int16_T *); /* C55x asm file for FIR filter */ 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); } } /* C function firproc for FIR filtering */ static int firproc(int *input, int *output) { /***************************************************************** * Define variable arrays, define and clear variables *****************************************************************/ long yn = 0; /* y(n), output of FIR filter */ int xnbuf[96]; /* signal buffer for FIR filter */ int i,k; int size = 300; for(k=0;k0;i--) { xnbuf[i]=xnbuf[i-1]; /* refresh signal buffer */ } xnbuf[0]=*input++; /*insert newest sample into buffer*/ /************************************************************* * FIR filtering: * y(n) = sum[x(n-i)*b(i)] for i = 0 to BL-1 *************************************************************/ yn = 0; yn = fir_c55(xnbuf,NL,NUM); /* FIR filtering in assembly */ *output++ = (int)(yn); } return(TRUE); } /* Function for dataIO */ static void dataIO() { return; }