Digital Signal Processing Reference
In-Depth Information
// RTDX_MATLABFFT.c RTDX-MATLAB for data transfer PC->DSK(with loop)
#include "dsk6713_aic23.h" //codec-DSK support file
#include <rtdx.h> //RTDX support file
Uint32 fs=DSK6713_AIC23_FREQ_16KHZ; //set sampling rate
RTDX_CreateOutputChannel(ochan); //create out channel C6x-->PC
void main()
{
short i, input_data[256]={0}; //input array size 256
comm_poll(); //init DSK, codec, McBSP
IRQ_globalEnable(); //enable global intr for RTDX
IRQ_nmiEnable(); //enable NMI interrupt
while(!RTDX_isOutputEnabled(&ochan)) //wait for PC to enable RTDX
puts("\n\n Waiting... ");
//while waiting
while(1)
// infinite loop
{
i=0;
while (i<256) //for 256 samples
{
input_data[i] = input_sample(); //defaults to left channel
output_sample(input_data[i++]); //defaults to left channel
}
RTDX_write(&ochan,input_data,sizeof(input_data));//send 256 samples
}
}
FIGURE 9.8. C program that runs on the DSK to illustrate RTDX with MATLAB. Input
from the DSK is sent to MATLAB ( rtdx_matlabFFT.c ).
Access MATLAB and make the following directory (path) active:
c
6713 \
myprojects rtdx
\
_
matlabFFT
This folder contains the necessary files associated with this project. Within
MATLAB, run the ( .m ) file rtdx _ matlabFFT . Verify that the executable (.out) file is
being loaded and run within CCS. Input a sinusoidal signal with a frequency of 2 kHz
and verify that the output is the delayed (attenuated) input signal (a loop program).
Within MATLAB the plot shown in Figure 9.10 is displayed on the PC monitor,
which is the FFT magnitude of the input sinusoidal signal. Vary the frequency of the
input signal to 3 kHz and verify the FFT magnitude displaying a spike at 3 kHz.
The FFT is executed on the PC host. As a result, on an older/slower PC, chang-
ing the input signal frequency will not yield a corresponding FFT magnitude plot
immediately. Note : If it is desired to transfer data from the PC to the DSK, an input
channel would be created using
RTDX_CreateInputChannel(ichan);
While(! RTDX_isInputEnabled(&ichan));
RTDX_read(&ichan, . . )
.
Search WWH ::




Custom Search