14
Software Examples
14 – 7
M3 = (1 - length of delay line buffer)
Return Value:
SR1 = output sample Y(n)
Altered Registers:
SE, MX0, MX1, MY0, MR, SR
Computation Time (with N even):
ADSP-2101/2102: (8 x N/2) + 5 cycles
ADSP-2100/2100A: (8 x N/2) + 5 + 5 cycles
All coefficients and data values are assumed to
be in 1.15 format
}
.ENTRY
biquad;
biquad:
CNTR = number_of_biquads
DO sections UNTIL CE;
{Loop once for each biquad}
SE=DM(I1,M2);
{Scale factor for biquad}
MX0=DM(I0,M0), MY0=PM(I4,M4);
MR=MX0*MY0(SS), MX1=DM(I0,M0), MY0=PM(I4,M4);
MR=MR+MX1*MY0(SS), MY0=PM(I4,M4);
MR=MR+SR1*MY0(SS), MX0=DM(I0,M0), MY0=PM(I4,M4);
MR=MR+MX0*MY0(SS), MX0=DM(I0,M1), MY0=PM(I4,M4);
DM(I0,M0)=MX1, MR=MR+MX0*MY0(RND);
sections:
DM(I0,M0)=SR1, SR=ASHIFT MR1 (HI);
DM(I0,M0)=MX0;
DM(I0,M3)=SR1;
RTS;
.ENDMOD;
Listing 14.2 Cascaded Biquad IIR Filter
14.5
SINE APPROXIMATION
The following formula approximates the sine of the input variable x:
sin(x) = 3.1 0.02026367x
2
– 5.325196x
3
+ 0.5446778x
4
+ 1.800293x
5
The approximation is accurate for any value of x from 0˚ to 90˚ (the first
quadrant). However, because sin(–x) = –sin(x) and sin(x) = sin(180˚ – x),
you can infer the sine of any angle from the sine of an angle in the first