Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need explanation for the lines of code in the filter function

Status
Not open for further replies.

patan.gova

Full Member level 3
Full Member level 3
Joined
Dec 19, 2011
Messages
172
Helped
4
Reputation
8
Reaction score
0
Trophy points
1,296
Visit site
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

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.
 

Hello!

The post is old, but since there is no reply...
Judging by your questions, I guess you didn't write this code. Why not writing your own code?
If you can't do it, then read some documentation, some books
Here is a good one:
Digital processing of signals
By Maurice Bellanger

Dora.

NB: I can't solve this problem. Negative index has no meaning.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top