Digital Signal Processing Reference
In-Depth Information
Example 5.6: Sine Generation Using a Difference Equation with C Calling
an ASM Function ( Sinegencasm )
This example is based on Example 5.3 with a C source program calling an ASM
function to generate a sine wave using a difference equation. Figure 5.24 shows the
C source program Sinegencasm.c calling the ASM function Sinegencasmfunc.asm
shown in Figure 5.25. The C source program shows the array y [3], which contains
the values y (0), y (1), and y (2) and the coefficient A, calculated to generate a
1.5-kHz sine wave. The address of the array y [3], along with the coefficient A, is
passed to the ASM function through A4 and B4, respectively. The values in the array
y [3] and the coefficient A were scaled by 2 14 to allow for a fixed-point implementa-
tion. As a result, within the ASM function, A8 initially containing A y ( n
-
1) is scaled
back (shifted right) by 2 14 .
Build this project as Sinegencasm . Verify that a 1.5-kHz sine wave is gener-
ated. Verify that changing the array to y [3]
=
{0, 16384, 0} and A
=
0 yields a 2-kHz
sine wave.
5.5 ASSIGNMENTS
1. Design and implement in real time a 12 th -order IIR lowpass filter using a
Chebyshev type 2, with a cutoff frequency of 1700 Hz and a sampling fre-
quency of 8 kHz. Compare/discuss the characteristics of this filter in terms of:
(a) the order of the filter
(b) the filter's type with an Elliptical and Butterworth design. If it has been
designed with MATLAB, then illustrate with the appropriate frequency
responses from MATLAB plots.
2. Write a program using a difference equation to generate a swept sinusoidal
waveform with a frequency range between 400 and 3700 Hz.
3. Write a program using a difference equation to generate a 1-kHz cosine wave.
Similar to the second-order difference equation used in Example 5.3 to gen-
erate a sine wave, the following equation generates a cosine wave:
() =
(
) +
(
) +
() - (
) ¥-
(
)
yn
Ayn
-
1
Byn
-
2
xn
A
2
n
1
with zero initial conditions, and A
=
2cos wT and B
=-
1. Assume an impulse
at n
=
0, such that x (0)
=
1 and y (
-
1)
=
y (
-
2)
=
0. Then
() = () + () +
() - (
)
() =
n
=
0
:
:
:
y
0
Ay
1
By
2
x
0
A
2
x
1
1
() =
() + () +
() - (
) ( ) =-
n
=
11
y
Ay
0
By
11
x
A
20
x
A
A
2
() =
() +
() +=
(
) +
n
=
2
y
2
Ay
1
By
0
0
A A
-
A
2
B
Search WWH ::




Custom Search