AnsweredAssumed Answered

Fir filter result

Question asked by Sisik2205 on Jan 25, 2013
Latest reply on Feb 5, 2013 by MaheshN

Hello society, it's me again with my silly little question.

If you don't mind I will use this thread in the future as well because I plan to optimize the FIR as much as I can.

So here is the code (example from the older processors):

#define samples 10

#define taps 3

 

 

int input[samples] = {1,2,3,4,5,6,7,8,9,10};

int output[samples];

int pm coefficients[taps] = {2,4,6};

int dm state[taps+1] = {0,0,0};

 

 

void main()

{              

   int temp;  

   int i;

   int j;

   int k;

   for (k = 0; k < samples; k++)

   {

      state[0] = input[k];

            for (i = 0, temp = 0; i < taps; i++)

                      {

         temp += coefficients[i] * state[i];

                      }

      output[k] = temp;

      for (j = taps-1; j > taps; j--)

                {

         state[j+1] = state[j];

                }

   }

   for (k = 0; k<samples; k++)

          {

                    printf("%d ",output[k]);

          }

    exit(0);

}

 

I've just changed coefficients and added the printing loop. But as the result of this filtring operation it shows me that the output is 2 4 6 8 10 12 14 16 18 20, while it should be 2 8 20 32 ... Can you tell me if there is any mistake in this code? I keep on looking at it and I have even written thissituation operation by operation on a paper and it seems ok, but it's apparently not.

 

Thanks in advance.

 

Regards,

Bartek

Outcomes