Digital Signal Processing Reference
In-Depth Information
% RTDX_MATLABFFT.m MATLAB-DSK interface with loop. Calls CCS,
%loads .out file. Data from DSK MATLAB for FFT and plotting
ccsboardinfo %board info
cc=ccsdsp('boardnum',0); %setup CCS object
reset(cc); %reset board
visible(cc,1);
%for CCS window
enable(cc.rtdx);
%enable RTDX
if ~isenabled(cc.rtdx);
error('RTDX is not enabled')
end
cc.rtdx.set('timeout', 20); %set 20sec timeout for RTDX
open(cc,'rtdx_matlabFFT.pjt'); %open project
load(cc,'./debug/rtdx_matlabFFT.out'); %load executable file
run(cc);
%run program
configure(cc.rtdx,1024,1);
%configure one RTDX channel
open(cc.rtdx,'ochan','r');
%open output channel
pause(3)
%wait for RTDX channel to open
fs=16e3;
%set sample rate in MATLAB
fftlen=256;
%FFT length
fp=[0:fs/fftlen:fs/2-1/fftlen];
%for plotting within MATLAB
enable(cc.rtdx,'ochan');
%enable channel from DSK
isenabled(cc.rtdx,'ochan');
for i=1:2048 %obtain 2048 buffers then stop
outdata=readmsg(cc.rtdx,'ochan','int16'); %read 16-bit data from DSK
outdata=double(outdata); %32-bit data for FFT
FFTMag=abs(fftshift(fft(outdata))); %FFT using MATLAB
plot(fp,FFTMag(129:256))
title('FFT Magnitude of data from DSK');
xlabel('Frequency');
ylabel('Amplitude');
drawnow;
end
halt(cc); %halt processor
close(cc.rtdx,'ochan'); %close channel
clear cc %clear object
FIGURE 9.9. MATLAB program that runs on the host PC to illustrate RTDX with
MATLAB. MATLAB's FFT and plotting functions are used ( rtdx_matlabFFT.m ).
This creates an input channel, waits for the input channel to be enabled, and reads
the data (input to the C6x on the DSK). In the MATLAB program, the following
lines of code
open(cc.rtdx,' ichan', ' w' );
enable(cc.rtdx,' ichan' );
writemsg(. . .);
open and enable an input channel and then write (send) the data from MATLAB
running on the host PC to the C6x on the DSK. See Example 9.4.
Search WWH ::




Custom Search