matlab and ccs interface manual with filter program
TRANSCRIPT
EdGate Technologies V1.0
Page 1
MATLAB SIMULINK INTERFACE
WITH TI DSK C6713(CCSTUDIO)
USER MANUAL
EdGate Technologies
#68,15th Cross, 1st Block,
R.T.Nagar, Bangalore: 560 032
PH: 080 23535125 /8.
www.edgate.in
EdGate Technologies V1.0
Page 2
Contents
Requirement verification
System requirements
Mathworks software requirements
Texas instruments software requirements
Hardware set up
Procedure to run demo program
Procedure for creating new model
FIR Filter
IIR Filter
Aaudio loopback with sw,LED,reset peripheral
Modulation and Demodulation
EdGate Technologies V1.0
Page 3
MATLAB And DSP
INTRODUCTION
The Embedded Target for TI C6000 DSP integrates MATLAB and Simulink
with Texas Instruments eXpressDSP tools and C6000 DSPs.
Together, these products enable you to perform automatic code
generation, prototyping, and embedded system deployment of
signal processing applications on TI C6000 processors.
By using the Embedded Target for TI C6000 DSP and your TI development
tools with Real-Time Workshop and Real-Time Workshop Embedded Coder
(both available separately), you can generate a real-time C language
implementation of your Simulink model
TheEmbedded Target for TI C6000 DSP supports TI C67x
loating-point DSPs and C64x and C62x fixed-point DSPs,
including onboard and onchip DSP peripherals.
It automates the creation of Code Composer Studio projects and supports
several evaluation boards, including the DM642EVM, C64 I 6DSK, C671 3DSK,
C6711DSK, and C670IEVM.
EdGate Technologies V1.0
Page 4
KEY FEATURES ■ Generates documented, readable C code in Code Composer Studio project
format using Real time Workshop (RTW). This generated code can be edited
for further changes. The Embedded Target for C6000 DSP Platform integrates
Simulink and MATLAB with TI's eXpressDSP tools and C6000 DSP processors.
It consists of Simulink libraries for designing and simulating DSP applications.
These libraries include key operations such as
Multirate, and adaptiveiltering
transforms
matrix manipulation and linear algebra
statistics
spectral analysis
Using these libraries you can develop digital signal processing applications that have
any of the following characteristics:
■ Single rate
■ Multirate
■ Multistage
■ Adaptive
EdGate Technologies V1.0
Page 5
Matlab used must be compatible with ccstudi oversion (for example matlab2007A compatible with ccs3.1 and ccs3.3,
matlab2008A and B are also compatible with ccs3.1,for more information on compatibility check matworks website)
EdGate Technologies V1.0
Page 7
Hardware setup
We will make use of function generator and an oscilloscope. Both will be connected to the TI C6713 on line-in and
line-out connectors. Frequency of Carrier Signal is fixed at 15 kHz while the message signal is varried from the
function generator. Since DSK C6713 ensures realtime simulation, once the message signal is varied we will see on
oscilloscope that modulated signal is also varying. Lets discuss different steps involved.
c6713 Simulink Mode
EdGate Technologies V1.0
Page 8
Procedure to run demo program
To run demo program
1)install ccstudio v3.1or 3.3 and also install compatible matlab2007A(7.4)
2)configure ccstudio according to your external target board
3)close down the ccstudio window
4)open up the matlab window
1. type ccstutorial press enter
The 'Link for Code Composer Studio' provides a direct connection between MATLAB and a
DSP in Code Composer. This provides a mechanism for controlling and manipulating an
embedded application using the full computational power of MATLAB. This can be used to
assist DSP debugging and development.Another possible use is for creation of MATLAB scripts
forverification and testing of algorithms that exist in their final implementation on an actual DSP
target.Before discussing the methods available with the link object,it's necessary to select a DSP
target. When the link is created, it is specific to a particular CPU, (i.e. a DSP processor) so
selection is required before proceeding. In general, the selection process is only necessary for
multiprocessor configurations of Code Composer Studio
2. Press any key to continue
The 'Link for Code Composer Studio' provides two tools for selecting a DSP board and processor
in multiprocessorconfigurations. First, a command line version called: 'ccsboardinfo' which
generates a list of the available boards and processors.For scripting, this command can return a
structure, which can be applied programmatically to select a particular DSP chip.
3. Press any key to continue: ccsboardinfo
ccsboardinfo
Board Board Proc Processor Processor
Num Name Num Name Type
0 C6713 DSK 0 CPU_1 TMS320C6x1x
EdGate Technologies V1.0
Page 9
echo off;
Another selection option is a GUI tool called 'boardprocsel'. Please Note - the CPU that is
selected in the GUI will be used for the rest of this tutorial. For single processor installations, of
Code Composer Studio, simply select 'OK' from the message box to continue.
4. Press any key to continue, then select aDSP from the GUI (or click OK):
boardprocsel
[boardNum,procNum] = boardprocsel
boardNum = 0
procNum =0
drawnow;
echo off
The goal of this selection process is a board numberand processor number that uniquely identify
a particulartarget DSP. These values are then applied during the link creation.You selected
board number = 0, and processor number = 0Next, the actual connection between the MATLAB
command line and Code Composer will be established. This link is represented by a MATLAB
EdGate Technologies V1.0
Page 10
object, which for this session will be saved in variable 'cc'. The link object is created with the
'ccsdsp' command, which accepts the board number and processor number as input parameters.
Other properties can also be defined during the object creation; refer to the 'ccsdsp'
documentation for more information on these properties.The generated 'cc' object will be used to
direct actions to the designated DSP chip. Therefore, it will appear in all commands that follow
the object creation. Naturally, in multiprocessor implementations it is possible to have more than
one link object.
NOTE: Before proceeding, your DSP hardware should be reset and configured as needed for
operation by Code Code Composer.
5. Press any key to continue: ccsdsp
cc = ccsdsp('boardnum',boardNum,'procnum',procNum)
CCSDSP Object:
Processor type : TMS320C6713
Processor name : CPU_1
Running? : No
Board number : 0
Processor number : 0
Default timeout : 10.00 secs
RTDX channels : 0
timeoutValue = 10; % time-out value in seconds
set(cc,'timeout',timeoutValue); % Set CCSDSP default time-out value
echo off
You may have noticed Code Composer appear briefly when 'ccsdsp' was called. If Code
Composer was not running before the link is established, it is started and then placed in the
background.In most cases, you will need to interact with Code Composer, so the first method
that will be introduced (called 'visible')controls the state of Code Composer on the desktop. This
accepts a Boolean input that makes Code Composer visible (1) or invisible (0) on the desktop.
For the rest of this tutorial, we will need to interact with Code Composer, so we'll use 'visible' to
bring it up to the desktop.
EdGate Technologies V1.0
Page 11
ERROR1:
Solution:
make sure that your dsp board is correctly connect.
remove power supply and reconnect it and try the above comments ie ccsdsp
ERROR2:
cc = ccsdsp('boardnum',boardNum,'procnum',procNum)catch
echo off
Error using ==> ccs.ccsdsp.initializeCcsdsp>DetectConfigErrors at 173
EdGate Technologies V1.0
Page 12
Could not connect to CCS. Please ensure your CCS installation is set up properly.
Exiting CCSTUTORIAL demo...
Solution:
Make sure that your usb cable is connect properly,remove and reconnect and try
Make sure that your matlab version support your ccs version(2007A is compatible with ccs3.1
and ccs3.3)
IF stil giving ths same error then uninstall all ccstudio files and TI drivers from your PC also
uninstall matlab and its related files.then again install ccstudio and matlab
6. Press any key to continue
visible(cc,1) % Force Code Composer to be visible on the desktop
echo off
With the link in place, it is now possible from MATLAB touery Code Composer for status on the
specified DSP.Four methods are available to get status information:
'info' - returns a structure of testable Target conditions.
'display' - prints a list of information about the target CPU.
'isrunning' - returns the state (running or halted) of the CPU.
'isrtdxcapable' - reports CPUs ability to perform RTDX(tm) transfers.
The next segment will demonstrate these methods.
7. Press any key to continue: display
display(cc)
CCSDSP Object:
Processor type : TMS320C6713
Processor name : CPU_1
Running? : No
EdGate Technologies V1.0
Page 13
Board number : 0
Processor number : 0
Default timeout : 10.00 secs
RTDX channels : 0
8. Press any key to continue: info, isrunning
linkinfo = info(cc)
linkinfo =
procname: 'CPU_1'
isbigendian: 0
isrtdxcapable: 1
family: 320
subfamily: 103
revfamily: 13
targettype: 'emulator'
siliconrev: 16973824
timeout: 10
boardname: 'C6713 DSK'
cpurunstatus = isrunning(cc)
cpurunstatus = 0
isrtdxcapable(cc)
ans = 1
echo off
From the 'subfamily' and 'revfamily' members of the structure returned by the 'info' method, it
was determined that you selecteda TMS320C6713.Please note - In some cases, the values
reported by Code Composer do not match the physical device numbering scheme.Now that a
connection has been established, the target CPU needs something to do! Therefore, the next step
EdGate Technologies V1.0
Page 14
is to create executable code for the target DSP with Code Composer. For this tutorial, a Code
Composer project file and a board specific executable were created and included with MATLAB.
We will first attempt to load the included executable directly, and if the load fails (could be
because it is a different board or processor), we will build the included project. The following set
of commands will locate the tutorial project and load it into Code Composer. This will use the
'open' method, which can direct Code Composer to load a project file or a program file.
9. Press any key to continue: open,cd
% Open the CCS Project
demoPjt = getDemoProject(cc,'ccstutorial')
demoPjt =
isLibProj: 0
TemplateProject:
'C:\ProgramFiles\MATLAB\R2007a\work\LinkForCCSDemos_v3.0\template\c6x\c67x.pjt'
DemoDir
'C:\Program Files\MATLAB\R2007a\work\LinkForCCSDemos_v3.0\ccstutorial\c6x\c67x'
ProjectFile:
'C:\ProgramFiles\MATLAB\R2007a\work\LinkForCCSDemos_v3.0\ccstutorial\c6x\c67x\ccstut.
pjt'
ProgramFile: '
C:\ProgramFiles\MATLAB\R2007a\work\LinkForCCSDemos_v3.0\ccstutorial\c6x\c67x\ccstut.
out'
SrcFile: {2x1 cell}
LibFile: ''
CmdFile:
{'C:\Program Files\MATLAB\R2007a\toolbox\ccslink\ccsdemos\shared\c6x\c6x.cmd'}
HdrFile: ''
EdGate Technologies V1.0
Page 15
BuildOpts: [1x1 struct]
ProjectAction: 'upToDateProj-upToDateProg'
RebuildDemo: 0
demoPjt.ProjectFile
ans =
C:\ProgramFiles\MATLAB\R2007a\work\LinkForCCSDemos_v3.0\ccstutorial\c6x\c67x\ccstut.
pjt
demoPjt.DemoDir
ans =
C:\Program Files\MATLAB\R2007a\work\LinkForCCSDemos_v3.0\ccstutorial\c6x\c67x
cd(cc,demoPjt.DemoDir) % Change working directory of Code Composer(only)
echo off
You should notice the tutorial's project loaded in Code Composer.Examine the files in Code
Composer that comprise this project the main source file used by this tutorial is 'ccstut.c', a
linker command file (*.cmd) and vector table source file (*.asm), which will be different,
depending on the DSP family you are using. Before building this project, we will attempt to load
the included executable. This will use the 'load' method, which should only be used for program
files.The 'Link for Code Composer Studio' includes methods for reading the target's symbol table
to give direct access to data in the DSP memory. NOTE: The symbol table is only available after
the program file is built and then loaded into the DSP. Notice the results of checking the symbol
table for the variable 'ddat' before and after the load.
EdGate Technologies V1.0
Page 16
10. Press any key to continue: load,address,dec2he
% Before loading target execution file:
warnState = warning('on'); % Enable warnings to demonstrate the next command
address(cc,'ddat') % Note - This may (correctly) issue a warning before the executable file is
loaded.
Warning: Address: Failed to locate symbol 'ddat' in symbol table in C:\Program
Files\MATLAB\R2007a\toolbox\ccslink\ccslink\@ccs\@ccsdsp\address.p>address at 51 In
ccstutorial at 274
ans =[]
warning(warnState); % Reinstate warning state
% Load the target execution file
load(cc,demoPjt.ProgramFile,30)
echo off
% Assume that the target execution file has been loaded by the user ddatA = address(cc,'ddat')
% Read the address of global: ddat
ddatA = 38848 0
dec2hex(ddatA) % in hexadecimal (address and page)
ans =97C0 0000
echo off
After the target code loaded, it is possible to examine and modify data values in the DSP target
from MATLAB.For static data values, it is possible to read them immediately after loading a
program file. However, the more interesting case is to manipulate data values at intermediate
points during program execution.To facilitate this operation, there are methods to insert (and
delete) breakpoints in the DSP program. The method 'insert' creates a new breakpoint, which can
EdGate Technologies V1.0
Page 17
be specified by either a source file location or a physical memory address.For this tutorial, we
need to insert a breakpoint at line 64 of the 'ccstut.c' source file.To assist your visibility of this
action, the method 'open' is used to display the source file in Code Composer. Furthermore, the
'activate' method will force this file to the front.(Although it is not demonstrated here, 'delete'
can be used to remove a breakpoint.)
11. Press any key to continue: activate, insert and open
cd(cc,demoPjt.DemoDir); % Restore back working directory for Code Composer
brkpt = 64;
demoPjt.SrcFile{1}
ans =
C:\Program Files\MATLAB\R2007a\toolbox\ccslink\ccsdemos\ccstutorial\ccstut.c
[srcpath,srcfile,ext] = fileparts(demoPjt.SrcFile{1});
srcfile = [srcfile ext];
cc.cd(srcpath);
open(cc,srcfile,'text') % Be sure this file is open for viewing in CCS
activate(cc,srcfile,'text') % Bring the source file forward
insert(cc,srcfile,brkpt) % Insert breakpoint at line 64
echo off
Examine the source file 'ccstut.c' in the Code Composer Studio source editor area. There should
be a breakpoint on line 64 (indicated by a red dot). Next, locate the two global data arrays: 'ddat'
and 'idat', which are located at lines 44 and 45 in this file. These DSP memory arrays can be
accessed directly from MATLAB command line using the 'read' and 'write' methods.To control
target execution, use the 'run','halt' and 'reload' methods. The following section will demonstrate
these methods.
Note: This approach to access DSP memory is powerful but rudimentary. Later in the tutorial,
we'll introduce an easier method based on C variables (supports C6x, C54x, C55x, R2x, R1x,
OMAP
EdGate Technologies V1.0
Page 18
12. Press any key to continue: halt,reset,reload,run,read
ddat_addr = address(cc,'ddat'); % Get address of symbols
idat_addr = address(cc,'idat');
echo off
ddat_type = 'double'; % Set values to use
idat_type = 'int16';
ddat_value = double([pi 12.3 exp(-1) sin(pi/4)]);
idat_value = int16(1:4);
echo off
halt(cc) % Halt the CPU (if necessary)
echo off
reset(cc); % Reset the CPU (if necessary)
echo off
reload(cc) % reload the .out file and set the PC to start of the program
ans =
C:\ProgramFiles\MATLAB\R2007a\work\LinkForCCSDemos_v3.0\ccstutorial\c6x\c67x\ccstut.
out
run(cc,'runtohalt',30);
% Wait for program execution to stop at breakpoint! (timeout = 20 seconds)
ddatV = read(cc,address(cc,'ddat'),ddat_type,4) % Should equal initialized value from C-Code
ddatV =16.3000 -2.1300 5.1000 11.8000
idatV = read(cc,address(cc,'idat'),idat_type,4)
EdGate Technologies V1.0
Page 19
idatV = -1 508 647 7000
Compare Data: idat, ddat with Code Composer,
then press return write(cc,address(cc,'ddat'),ddat_value)
% Modify memory values
write(cc,address(cc,'idat'),idat_value)
run(cc,'runtohalt',20); % Resume execution from breakpoint, then modify
ddatV = read(cc,address(cc,'ddat'),ddat_type,4) % Read memory values
ddatV =3.1416 12.3000 0.3679 0.7071
idatV = read(cc,address(cc,'idat'),idat_type,4)
idatV = 1 2 3 4
restart(cc); % Reset the PC to start of program
For Assembly language programmers, there are also methods to access CPU registers: 'regread'
and 'regwrite'.Press any key to continue: regread,regwrite
tReg = regread(cc,'A0','2scomp') % 2's complement version of A0
tReg = 0
regread(cc,'B2','binary') % unsigned version of B2
ans = 0
regwrite(cc,'A2',tReg,'2scomp')
regread(cc,'A2','2scomp') % verify the value previously written
ans =0
EdGate Technologies V1.0
Page 20
echo off
Direct access to DSP memory is powerful, but for C programmers it is more convenient to
manipulate memory in ways consistent with the defined C variables. This type of access is
implemented using MATLAB objects as representations of embedded entities. First, let's take a
look at the same data values that we explored above but now we'll manipulate them using
objects. First, we'll restart the program and apply the 'list' method, which queries Code
Composerfor information, on 'idat', i.e. the global C variable of intere
13. Press any key to continue: list, goto, run
restart(cc) % Restart program
goto(cc,'main') % Open file where 'main' is found and set the CCS cursor to the start of 'main'
run(cc,'main') % Run to start of 'main' - ensured Embedded C variables get initialized
listI = list(cc,'variable','idat') % Returns structure of information about global variable:
'idat'listI =
idat: [1x1 struct]
listI.ida
ans =
name: 'idat'
isglobal: 0
address: [38836 0]
size: 4
bitsize: 16
type: 'short'
EdGate Technologies V1.0
Page 21
14. Press any key to continue
'List' generates lots of information about the embedded 'idat' variable.However, an even more
useful method is 'createobj', which generates a MATLAB object to represent the C variable.
This object acquires the properties of the C variable. Applying the object returned by
'createobj',you can directly read the entire variable or access individual elements of an array.
Note: Up to this point all methods were applied to the original 'cc' object that was created with
'ccsdsp'. The 'cc' object represents communication with a particular embedded processor in
Code Composer Studio.However, for the remainder of this tutorial, methods are applied to many
different objects. In typical object-oriented fashion, the action performed by a method will
depend on it's object. The relevant object is always the first parameter passed to the method. For
example, in thefollowing section, 'cvar' is an object representing the embedded 'idat' variable.
15. Press any key to continue: createobj, read, write
cvar = createobj(cc,'idat') % Creates a MATLAB object 'cvar' to manipulate embedded 'idat'
NUMERIC Object stored in memory:
Symbol name : idat
Address : [ 38836 0]
Data type : short
Word size : 16 bits
Address units per value : 2 au
Representation : signed
Size : [ 4 ]
Total address units : 8 au
Array ordering : row-major
Endianness : little
EdGate Technologies V1.0
Page 22
read(cvar) % Reads the entire embedded array into the MATLAB workspace
ans = -1 508 647 7000
read(cvar,2) % Reads only the second element
ans = 508
write(cvar,4,7001) % Modifies the fourth element to 7001
read(cvar) % See changes
ans = -1 508 647 7001
read(cvar,[1 cvar.size]) % Read only first and last elements
ans = -1 7001
echo off
The previous 'read' takes the raw memory values and converts theminto equivalent MATLAB
numeric values. The conversion that gets applied is controlled by the properties of the object,
which were initially configured in 'createobj' to settings appropriate for your DSP architecture
and C representation. In some cases, it is useful to alter these default conversion properties.
Several properties such as 'endianness', 'arrayorder' and 'size' canbe directly modified using 'set'.
More complex changes are possible using methods such as 'convert' and 'cast', which adjust
multiple properties simultaneously.
16. Press any key to continue: cast, convert, size
set(cvar,'size',2) % Reduce size of 'idat' to first 2 elements
read(cvar)
ans =-1 508
uicvar = cast(cvar,'unsigned short') % Creates new object with specified data type (butotherwise
identical)
EdGate Technologies V1.0
Page 23
NUMERIC Object stored in memory:
Symbol name : idat
Address : [ 38836 0]
Data type : unsigned short
Word size : 16 bits
Address units per value : 2 au
Representation : unsigned
Size : [ 2 ]
Total address units : 4 au
Array ordering : row-major
Endianness : little
read(uicvar) % Note - first value is no longer -1, but unsigned equivalent
ans = 65535 508
convert(cvar,'unsigned short') % Same as Cast, but alters properties of existing class
NUMERIC Object stored in memory:
Symbol name : idat
Address : [ 38836 0]
Data type : unsigned short
Word size : 16 bits
Address units per value : 2 au
Representation : unsigned
Size : [ 2 ]
Total address units : 4 au
Array ordering : row-major
EdGate Technologies V1.0
Page 24
Endianness : little
read(cvar) % Remember - the size of cvar was set to 2!
ans =65535 508
echo off
DSP variables such as strings, structures, bitfields, enumerated typesand pointers can be
manipulated just as easily. The following demonstrates some common manipulations on
structures, strings and enumerated types. In particular, note the 'getmember' method,which
extracts a single field from a structure as a new MATLAB object.
17. Press any key to continue: getmember
cvar = createobj(cc,'myStruct') % Object that represents an embedded C structure
STRUCTURE Object stored in memory:
Symbol name : myStruct
Address : [ 38808 0]
Address units per value : 28 au
Size : [ 1 ]
Total Address Units : 28 au
Array ordering : row-major
Members : 'iy', 'iz'
read(cvar)
ans = iy: [2x3 double]
iz: 'MatlabLink'
write(cvar,'iz', 'Simulink') % Modify 'iz' field using actual enumerated name
EdGate Technologies V1.0
Page 25
cfield = getmember(cvar,'iz') % Extract object from structure
ENUM Object stored in memory:
Symbol name : iz
Address : [ 38832 0]
Word size : 32 bits
Address units per value : 4 au
Representation : signed
Size : [ 1 ]
Total address units : 4 au
Array ordering : row-major
Endianness : little
Labels & values
: MATLAB=0, Simulink=1, SignalToolbox=2, MatlabLink=3, EmbeddedTargetC6x=4
write(cfield,4) % Write to same enumerated variable by value
read(cvar)
ans =
iy: [2x3 double]
iz: 'EmbeddedTargetC6x'
EdGate Technologies V1.0
Page 26
18. Press any key to continue
cstring = createobj(cc,'myString') % Object that represents an embedded C structure
STRING Object stored in memory:
Symbol name : myString
Address : [ 38880 0]
Word size : 8 bits
Address units per value : 1 au
Representation : signed
Size : [ 29 ]
Total address units : 29 au
Array ordering : row-major
Endianness : little
Char conversion type : ASCII
read(cstring)
ans =Treat me like an ANSI String
write(cstring,7,'ME')
read(cstring)
ans =Treat ME like an ANSI String
write(cstring,1,127) % Set first location to numeric value 127 (a non-printable ASCII character)
readnumeric(cstring) % Read equivalent numeric values
ans =Columns 1 through 18
EdGate Technologies V1.0
Page 27
127 114 101 97 116 32 77 69 32 108 105 107 101 32 97 110 32 65
Columns 19 through 29
78 83 73 32 83 116 114 105 110 103 0
echo off
To learn more about data manipulation and function calls,please run
'FUNCTIONCALLTUTORIAL'.
19. Press any key to continue
Finally, the objects created during this tutorial have COM handles to Code Composer Studio.
Until these handles are deleted, the Code Composer Studio process will remain in memory.
Exiting MATLAB will automatically remove these handles, but in some cases it might be useful
to manually delete them. Use 'clear' to remove objects from the MATLAB workspace and delete
any handles they contain. 'Clear all' will delete everything. Alternatively, to retain your
MATLAB data use 'clear' on the objects derived from 'ccsdsp' (including all objects returnedby
'createobj'). In addition, 'close' is performed on the tutorial project to remove it from Code
Composer.
20. Press any key to continue: close, clear
Finally, the objects created during this tutorial have COM handles to Code Composer Studio.
Until these handles are deleted, theCode Composer Studio process will remain in memory.
ExitingMATLAB will automatically remove these handles, but in some cases it might be useful
to manually delete them. Use 'clear' to remove objects from the MATLAB workspace and delete
any handles they contain. 'Clear all' will delete everything. Alternatively, to retain your
MATLAB data use 'clear' on the objects derived from 'ccsdsp' (including all objects returned
by 'createobj'). In addition, 'close' is performed on the tutorial project to remove it from Code
Composer.
% Clean-up Code Composer
close(cc,demoPjt.ProjectFile,'project') % close the project file
EdGate Technologies V1.0
Page 28
visible(cc,0); % Delete breakpoint introduced earlier
srcfile
srcfile = ccstut.c
delete(cc,srcfile,brkpt) % Remove breakpoint at line 64
close(cc,srcfile,'text') % Close source file
% Clear data objects
clear cc cvar cfield uicvar cstring
**************** Demo complete. ****************
EdGate Technologies V1.0
Page 29
Procedure for creating newsimulink model model
1) Make sure that ccstudio v3.1or 3.3 and compatible matlab2007A(7.4) are installed
2) hardware connection
I. connect a c6713 DSK board to the pc through USB
II. connect +5v power supply to the board
III. run the diagnostics
3) configure ccstudio according to your external target board
4) close down the ccstudio window
5) open up the matlab window
6) Type the following comments to make sure that correct board is selected and link is
made with ccstudio and matlab
a)ccsboardinfo
EdGate Technologies V1.0
Page 30
b)boardprocsel
[boardNum,procNum] = boardprocsel
boardNum = 0
procNum =0
drawnow;
Click on ok
c) type ccsdsp (establish connection between ccstudio and matlab)
cc = ccsdsp('boardnum',boardNum,'procnum',procNum)
CCSDSP Object:
Processor type : TMS320C6713
EdGate Technologies V1.0
Page 31
Processor name : CPU_1
Running? : No
Board number : 0
Processor number : 0
Default timeout : 10.00 secs
RTDX channels : 0
timeoutValue = 10; % time-out value in seconds
set(cc,'timeout',timeoutValue); % Set CCSDSP default time-out value
7) library verification
type c6000lib on comments window of matlab
EdGate Technologies V1.0
Page 32
Fig1
a)c6000 dsp core support lib
To get below window click on c6000dsp core support block shown above
EdGate Technologies V1.0
Page 33
a)hostcommunication library
To get below window click on hostcommunication library block shown Fig1
c)RTDX instrumentation
To get below window click on RTDX instrumentation block shown Fig1
EdGate Technologies V1.0
Page 35
Target reference block
8) click on simulink icon on matlab window to open simulink library
browser
EdGate Technologies V1.0
Page 37
10) To create new model FILenewmodel or click on below shon
icon
11) Select c6713dsk drag and place in the new model
window(untitled)
Click on yes
EdGate Technologies V1.0
Page 38
12) Similarly drag and place all the required block on new model window
As shown bellow
Fig simple audio loop back
13) Make all neccessory interconnection between the blocks
EdGate Technologies V1.0
Page 39
14) Save the model:file save (give any name with .mdl
extension)click on save
15) Check and change the property of your simulink block placed on model
window by double clicking on particular block
a)Target reference property setting
EdGate Technologies V1.0
Page 40
Change the Operating system dsp/bios to none and click on apply
Make sure that cpu clock speed (MHZ) is same as target cpu clock speed(for c6713
its 225Mhz)
EdGate Technologies V1.0
Page 41
Memory /section
Use default memory (no change required in below window)
EdGate Technologies V1.0
Page 42
b) ADC/DAC property
ADC
Double click on LINE in c6713dsk ADC block as shown above
Chage ADC source to line in or mic in as you want
If line in is selected input must be given to the line in port (line in of aic23 codec) of
dsk board
If mic inis selected input must be given to the mic in port(mic in of aic23 codec) of
dsk board
EdGate Technologies V1.0
Page 43
Select sampling rate between 8khz to 96khz(in case of audio select 44.1khz)
Select appropriate data type(for above example select single)
Then click on ok
EdGate Technologies V1.0
Page 44
DAC property
Double click on c6713dsk DAC block as shown above
Word length=16-bit
Sampling rate=44.1kHz(same as ADC sampling rate)
Over flow mode=wrap
Click on Applyok
16) Click on save icon on model window
EdGate Technologies V1.0
Page 45
17) Realtime workshop configuration
Simulationconfiguration parameters(ctrl+E)
Solver
Type= fixed step solver=discrete(no continue state)
All others field are used as default
EdGate Technologies V1.0
Page 46
Real time workshoplink to CCS
Project option=custom
Built action=built_and_execute
Interrupt over notification method=no
Click on applyok
EdGate Technologies V1.0
Page 47
18) Click on incremental built icon as shown in bellow diagram
19) Now observe the flowing changes on matlab and ccs window
EdGate Technologies V1.0
Page 50
FIR FILTER
Fig2 FIR filter model
Place the digital filter design block in between ADC and DAC
Digital filter design block are found under signal processingfilter design toolbox
Drag and place in the model window as shown in fig2
EdGate Technologies V1.0
Page 51
Double click on digital filter design block in fig2 and set the property of the filter
Response type
Select any one of the response type according to your requirement
1)low pass
2)high pass
3)band pass
4)differenciator,multiband,Hilbert transformer etc
EdGate Technologies V1.0
Page 52
Design method
IIR
butterworth
Chebyshev typei
Chebyshev typeii
Elliptic
Maximally flat etc
FIR(select on your need for example we have selected equiripple )
Window
Least squares
Equiripple
EdGate Technologies V1.0
Page 53
Order of filter
Select appropriate order of the filter base on your requirement(here we have taken order
as 10)
Unit:
Select unit of the frequency as Hz or kHz
Sampling frequency
Type appropriate sampling frequency base on nyquist criteria(for audio we have atken
fs=48000hz)
Select fpass freq appropriately(9600hz)
Fstop freq (12000)
Then click on design filter
Click on incremental built
EdGate Technologies V1.0
Page 54
IIR FILTER
Fig3 IIR Filter model
Double click on digital filter design block in fig3 and set the property of the filter as shown
bellow
EdGate Technologies V1.0
Page 55
Order of filter
Select appropriate order of the filter base on your requirement(here we have taken order
as 10)
Unit:
Select unit of the frequency as Hz or kHz(Hz)
Sampling frequency
Type appropriate sampling frequency base on nyquist criteria(for audio we have atken
fs=4800hz)
Fstop freq (12000)
Then click on design filter
Click on incremental built
Aaudio loopback with sw,LED,reset peripheral
Fig4
EdGate Technologies V1.0
Page 57
3) Switch , LED and Reset
Double click on switch block and change the following property
Tick on sw0-sw3
Data tpes =integer
Click ok
Double click on LED block Click on ok
No change in reset block use as default
EdGate Technologies V1.0
Page 58
4) C6713DSK
Double click on c6713dsk block and change the property as shown above diagram
Operating system=none
Applyok
EdGate Technologies V1.0
Page 59
Modulation and demodulation
Open a new simulink model and library browser
Using Embedded Target For TIC6000 DSP menu select C6713 DSK Board Support.
Using the Embedded Target For TIC6000 DSP tool in the library browser, select C6713
DSK Board Support and add ADC for Line In, DAC for Line Out and Reset Switch.
You can extract all these from Simulink Library Browser.
Implement the simulink model of AM as shown bellow
EdGate Technologies V1.0
Page 61
ADC:Message signal Line in parameters and carrier signal parameters can be set as
following. This is very important. Set ADC Source as Line In, Sample Rate 32kHz, Word
Length 16-bit.
Carrier:Amplitude of the message signal can be change through function generator (up to
5KHz), whereas, frequency of the carrier signal is 15KHz.
EdGate Technologies V1.0
Page 62
Constant
DAC:sampling rate same as ADC ie 32khz
• The output modulated signal observe in oscilloscope is:
EdGate Technologies V1.0
Page 63
C6713 Simulink Model - Amplitude De-Modulation
Target the device in the similar manner as done above in amplitude modulation.
A low pass filter has been designed in the FDA Tool in such a way that only the
frequency of the message signal (5 KHz) is allow to pass through filter.
Design the low pass filter using FDA Tool in Matlab.
Export this filter to the simulink model
EdGate Technologies V1.0
Page 65
• Run the model and observe the output at the oscilloscope.