Digital Signal Processing Reference
In-Depth Information
Two sliders can readily be used, one to change the gain and the other to change
the frequency. A different signal frequency can be generated by changing the loop
index within the C program (e.g., stepping through every two points in the table).
When you exit CCS after you build a project, all changes made to the project can
be saved. You can later return to the project with the status as you left it before.
For example, when returning to the project after launching CCS, select Project
Æ
Open to open an existing project such as sine8_LED.pjt (with all the necessary
files for the project already added).
Example 1.2: Generation of the Sinusoid and
Plotting with CCS ( sine8_buf )
This example generates a sinusoid with eight points, as in Example 1.1. More impor-
tant, it illustrates CCS capabilities for plotting in both time and frequency domains.
The program sine8_buf.c , shown in Figure 1.8, implements this project. This
program creates a buffer to store the output data in memory.
Create this project as sine8_buf.pjt , and add the necessary files to the
project, as in Example 1.1 (use the C source program sine8_buf.c in lieu of
sine8_LED.c ). Note that the necessary header support files are added to
the project by selecting Project
Æ
Scan All File Dependencies. The necessary
// sine8_buf Sine generation. Output buffer plotted within CCS
#include "dsk6713_aic23.h" //codec-DSK support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
int loop = 0; //table index
short gain = 10; //gain factor
short sine_table[8]={0,707,1000,707,0,-707,-1000,-707};//sine values
short out_buffer[256];
//output buffer
const short BUFFERLENGTH = 256;
//size of output buffer
int i = 0;
//for buffer count
interrupt void c_int11()
//interrupt service routine
{
output_sample(sine_table[loop]*gain); //output sine values
out_buffer[i] = sine_table[loop]*gain; //output to buffer
i++;
//increment buffer count
if(i==BUFFERLENGTH) i=0;
//if @ bottom reinit count
if (++loop > 7) loop = 0;
//check for end of table
return;
//return from interrupt
}
void main()
{
comm_intr();
//init DSK, codec, McBSP
while(1);
//infinite loop
}
FIGURE 1.8. Sine generation with output stored in memory as well ( sine8_buf.c ).
Search WWH ::




Custom Search