Digital Signal Processing Reference
In-Depth Information
product of the carrier and baseband signals (within the output equation) is scaled
by 2
12
(shifted right by 12). Projects on modulation are included in Chapter 10.
Example 2.15: Sweep Sinusoid Using a Table with
8000 Points (
sweep8000
)
Figure 2.24 shows a listing of the program
sweep8000.c
, which generates a sweep-
ing sinusoidal signal using a table lookup with 8000 points. The header file
sine8000_table.h
contains the 8000 data points that represent a one-cycle sine
wave. Since the output rate is
F
s
8 kHz, 8000 points are chosen to represent a
1-second interval. The file
sine8000_table.h
(in the folder
sweep8000
) is gen-
erated with MATLAB using
=
1000*sin(2*pi*i*start_freq/8000)
//
Sweep8000.c
Sweep sinusoid using table with 8000 points
#include "DSK6713_AIC23.h" //codec-DSK support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
#include "sine8000_table.h" //one cycle with 8000 points
short start_freq = 100; //initial frequency
short stop_freq = 3500; //maximum frequency
short step_freq = 200; //increment/step frequency
short amp = 30; //amplitude
short delay_msecs = 1000; //# of msec at each frequency
short freq;
//variable frequency
short t;
short i = 0;
void main()
{
comm_poll(); //init DSK, codec, McBSP
while(1)
//infinite loop
{
for(freq=start_freq;freq<=stop_freq;freq+=step_freq)
{ //step thru freqs
for(t=0; t<8*delay_msecs; t++) //output 8*delay_msecs samples
{ // at each freq
output_sample(amp*sine8000[i]);//output
i = (i + freq) % 8000; //next freq sample
}
}
}
}
FIGURE 2.24.
Program to generate a sweeping sinusoid using a lookup table with 8000
points (
sweep8000.c
).
Search WWH ::
Custom Search