DSPRelated.com
Forums

Second order IIR filter in Dsp

Started by Uzair Hassan July 15, 2011
Dear all
i have a 2nd order IIR filter code for TMSC6x but there is some ambiguity in understanding this code. please help me in understanding this code, which is given as

/* Subroutine iir_2nd_d: Second order IIR filter */
/* (Double precision) */
/* Note: the output array can overlay the input. */
/* */
/* Input scaled down by a factor of 2 to prevent overflow */
void iir_2nd_d(Shortword input[],Shortword den[],Shortword num[],
Shortword output[],Shortword delin[],Shortword delout_hi[],
Shortword delout_lo[],Shortword npts)
{
Shortword i,temp;
Longword accum;
//////////////// ist 5 line of for loop expanation required
for (i = 0; i < npts; i++) {
accum = L_mult(delout_lo[0],den[1]); what is delout_lo & delout_hi ??
accum = L_mac(accum,delout_lo[1],den[2]);
accum = L_shr(accum,14); // why this shift ??? logic ??
accum = L_mac(accum,delout_hi[0],den[1]);
accum = L_mac(accum,delout_hi[1],den[2]);

accum = L_mac(accum,shr(input[i],1),num[0]);
accum = L_mac(accum,delin[0],num[1]);
accum = L_mac(accum,delin[1],num[2]);

/* shift result to correct Q value */
accum = L_shl(accum,2); /* assume coefficients in Q13 */

/* update input delay buffer */
delin[1] = delin[0]; data_move();
delin[0] = shr(input[i],1); data_move();

/* update output delay buffer */
delout_hi[1] = delout_hi[0]; data_move();
delout_lo[1] = delout_lo[0]; data_move();
delout_hi[0] = extract_h(accum);
temp = shr(extract_l(accum),2);
delout_lo[0] = temp & (Shortword)0x3FFF; logic();

/* round off result */
accum = L_shl(accum,1);
output[i] = round(accum);
}
}
please reply asap.
regards