patan.gova
Full Member level 3
- Joined
- Dec 19, 2011
- Messages
- 172
- Helped
- 4
- Reputation
- 8
- Reaction score
- 0
- Trophy points
- 1,296
- Activity points
- 2,776
Hi,
I am planning to implement the digital filters with MSP430 microcontroller and want to use this fir_filter function but I don't exactly know how it works
Here the static const int16_t coeffs[12] = {contains 12 cofficient values };
Can someo explain me
1)In z = mul16(coeffs[11], buf[(offset - 11) & 0x1F]); if offset=0; what the value of (offset - 11) & 0x1F will be ?
2)For first iteration(if i=0) what the value of this will be (offset - 22 + i) & 0x1F]?
3)Isn't the (offset - i)='zero' in buf[(offset - i) & 0x1F] for every iteration?
Thanks.
I am planning to implement the digital filters with MSP430 microcontroller and want to use this fir_filter function but I don't exactly know how it works
Code:
int16_t ir_filter(int16_t sample)
{ static int16_t buf[32];
static int offset = 0;
int32_t z;
int i;
buf[offset] = sample;
z = mul16(coeffs[11], buf[(offset - 11) & 0x1F]);
for (i = 0; i < 11; i++)
z += mul16(coeffs[i], buf[(offset - i) & 0x1F] + buf[(offset - 22 + i) & 0x1F]);
offset = (offset + 1) & 0x1F;
return z >> 15;
}
Here the static const int16_t coeffs[12] = {contains 12 cofficient values };
Can someo explain me
1)In z = mul16(coeffs[11], buf[(offset - 11) & 0x1F]); if offset=0; what the value of (offset - 11) & 0x1F will be ?
2)For first iteration(if i=0) what the value of this will be (offset - 22 + i) & 0x1F]?
3)Isn't the (offset - i)='zero' in buf[(offset - i) & 0x1F] for every iteration?
Thanks.