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

Hi Bartek,

I went through your code and I can see that the–

for (j = taps-1; j > taps; j--)should be replaced byfor (j = taps-1; j > -1; j--)to get the required output.Regards,

Mahesh