25-08-2017, 09:32 PM
Code:
clc;
ccsboardinfo %board info
cc=ccsdsp('boardnum',0); %set up 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',50); %set 50sec timeout for RTDX
open(cc,'spectrogram1.pjt'); %open CCS project
load(cc,'./debug/spectrogram1.out'); %load executable file
run(cc); %run program
configure(cc.rtdx,2048,1); %configure one RTDX channel
open(cc.rtdx,'ochan','r'); %open output channel
pause(3) %wait for RTDX channel to open
enable(cc.rtdx,'ochan'); %enable channel from DSK
isenabled(cc.rtdx,'ochan');
M = 256; %window size
N = round(M/2);
B = 128; %No. of blocks (128)
fs = 8000; %sampling rate
t=(1:B)*(M/fs); %spectrogram axes generation
f=((0:(M-1)/2)/(M-1))*fs;
set(gcf,'DoubleBuffer','on');
y = ones(N,B);
column = 1;
set(gca,'NextPlot','add');
axes_handle = get(gcf,'CurrentAxes');
set(get(axes_handle,'XLabel'),'String','Time (s)');
set(get(axes_handle,'YLabel'),'String','Frequency (Hz)');
set(get(axes_handle,'Title'),'String','\fontname{times}\bf Real-Time Spectrogram');
set(gca,'XLim', [0 4.096]);
set(gca,'YLim', [0 4000]);
set(gca,'XLimMode','manual');
set(gca,'YLimMode','manual');
for i = 1:32768
w=readmsg(cc.rtdx,'ochan','single'); %read FFT data from DSK
w=double(w(1:N));
y(:, column) = w';
imagesc(t,f,dB(y)); %plot spectrogram
column = mod(column, B) + 1;
end
halt(cc); %halt processor
close(cc.rtdx,'ochan'); %close channel
clear cc %clear object
NOTE: For this example works with CCS 2.2 and Matlab 6.5.
Procedure:
22. Create a new project with name spectrogram.pjt.
23. Open “spectrogram.cdb” from given CD and save it in your new
project folder.
24. Copy the following files from the CD to your new project folder
1) c6713dskinit . c
2) FFT.c
3) spectrogram_rtdx_mtl.c
4) c6713dskinit . h
5) hamming.cof
6) spectrogram_RTDX.m
25. Add “spectrogram.cdb”, “c6713dskinit.c” and “spectrogram_rtdx_mtl.c” to the current project.
26. Add the library file “dsk6713bsl.lib” to the current project
Path “C:\CCStudio\C6000\dsk6713\lib\dsk6713bsl.lib”
5. Set the following compiler options.
Select Project Build options.
Select the following for compiler option with Basic ( for category):
(1) c671x{mv6710} (for target version)
(2) Full symbolic debug (for Generate Debug info)
(3) Speed most critical(for Opt Speed vs. Size)
(4) None (for Opt Level and Program Level Opt)
Select The Preprocessor Category and Type for Define Symbols{d}:
CHIP_6713, and from Feedback category, select for Interlisting:
OPT / C and ASM{-s}
6 Build project.
7. Close CCS
8. Open MATLAB 6.5 and Run spectrogram_RTDX.m . within MATLAB ,CCS will
enable RTDX and will load and run the COFF(.out) executable file. Then
MATLAB will plot the spectrogram of an input signal .