Digital Signal Processing Reference
In-Depth Information
// IIR.c IIR filter using cascaded Direct Form II
//Coefficients a's and b's correspond to b's and a's from MATLAB
#include "DSK6713_AIC23.h" //codec-DSK support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
#include "bs1750.cof"
//BS @ 1750 Hz coefficient file
short dly[stages][2] = {0};
//delay samples per stage
interrupt void c_int11()
//ISR
{
short i, input;
int un, yn;
input = input_sample();
//input to 1st stage
for (i = 0; i < stages; i++)
//repeat for each stage
{
un=input-((b[i][0]*dly[i][0])>>15) - ((b[i][1]*dly[i][1])>>15);
yn=((a[i][0]*un)>>15)+((a[i][1]*dly[i][0])>>15)+((a[i][2]*dly[i][1])>>15 );
dly[i][1] = dly[i][0];
//update delays
dly[i][0] = un;
//update delays
input = yn;
//intermed out->in to next stage
}
output_sample((short)yn); //output final result for time n
return;
//return from ISR
}
void main()
{
comm_intr();
//init DSK, codec, McBSP
while(1);
//infinite loop
}
FIGURE 5.14. IIR filter program using second-order sections in cascade ( IIR.c ).
IIR Bandstop
The coefficient file bs1750.cof (Figure 5.15) is obtained from Appendix D. It
represents a tenth-order IIR bandstop filter designed with MATLAB's filter
designer SPTool, as shown in Figure D.2 in Appendix D. Note that MATLAB's filter
designer shows the order as 5, which represents the number of second-order stages.
The coefficient file contains the numerator coefficients, a 's (three per stage), and
the denominator coefficients, b 's (two per stage). The a 's and b 's used in this topic
correspond to the b 's and a 's used in MATLAB.
Build and run this project as IIR . Verify that the output is an IIR bandstop filter
centered at 1750 Hz. Figure 5.16 shows the output frequency response of this IIR
bandstop filter obtained with an HP signal analyzer (with noise as the input).
IIR Bandpass and Lowpass
1. Rebuild this project using the coefficient file bp2000.cof (on the accompa-
nying CD), which represents a 36th-order (18 stages) Chebyshev type 2 IIR
bandpass filter centered at 2 kHz. This filter was designed with MATLAB, as
Search WWH ::




Custom Search