Digital Signal Processing Reference
In-Depth Information
if 0
. Therefore, lines 14 and 15 are used to reset the value of sample
if it is greater than 2
n
2
π
.from
x will not change the value of the output. Line 17 calculates the sine value
at the current sample point. The value is typecast as (short) before it is stored
in the variable sine value. Typecasting tells the compiler to convert a value
from one data type to another before storing it in a variable or sending it to
a function. In this case, the value returned from the sin() is a single precision
floating-point number (between -1.0 and 1.0) that gets scaled by amplitude
value (20000). By typecasting this number as a short (16-bit signed integer
between the values -32768 and 32767), the CPU will round the number to
the nearest integer and store it in a 16-bit signed integer format (2's comple-
ment). This value is scaled by 20000 for two reasons. First, it is needed so
that rounding errors are minimized, and second, it amplifies the signal so it
can be observed on the oscilloscope and heard through speakers or head-
phones. This scaling factor must be less than 32768 to prevent overdriving
the codec. Line 18 sends the current sine_value to the codec by calling the
function output_sample() . The code for output_sample() is located in file
C6xdskinit.c . Open the file C6xdskinit.c in CCS and examine the code for
this function. This function output_sample() forces the least significant digit
of the sample that it receives to zero and sends it to a function
mcbsp0_write() , which writes the sample to the transmit buffer in the McBSP.
This will cause the McBSP to transmit the data sample to the on-board codec.
The masking of the least significant digit of the output sample is needed so
that the on-board codec interprets the received binary number as a data
sample and not as secondary information. Upon completion of the interrupt
(generating a sinusoid sample and outputting it to the on-board codec), the
interrupt service routine restores the saved execution state (see the command
return; in line 19). In this program, the saved execution state will always be
the infinite while loop in the main() function.
π
. Because sin( x ) is periodic 2
π
in x , subtracting 2
π
Step 3: Using a Watch Window
Once an algorithm has been coded, it is good to have software tools for
observing and modifying the local and global variables after a program has
been loaded onto the DSK. Located in CCS is a software tool called a Watch
Window , which allows the user to view local variables and to view and
modify global variables during execution. In this lab, we will not view any
local variables, but we will view and modify global variables.
In CCS, start running the program sine_gen.out again and make
sure that you have a valid output on an oscilloscope.
Then click on the pull-down menu view , and select Watch Window .
A subwindow should appear on the bottom of the main CCS window.
You should notice two tabs on the bottom left part of the new
subwindow: Watch Locals and Watch 1 .
Click on the tab Watch 1 .
Search WWH ::




Custom Search