8/12/2019 c6713with Matlab User Manual1
1/49
8/12/2019 c6713with Matlab User Manual1
2/49
EdGate Technologies V1.0
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
8/12/2019 c6713with Matlab User Manual1
3/49
EdGate Technologies V1.0
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.
8/12/2019 c6713with Matlab User Manual1
4/49
ate Technologies V1.0
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
8/12/2019 c6713with Matlab User Manual1
5/49
ate Technologies V1.0
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 websi
8/12/2019 c6713with Matlab User Manual1
6/49
ate Technologies V1.0
8/12/2019 c6713with Matlab User Manual1
7/49
ate Technologies V1.0
Hardware setup
We will make use of function generator and an oscilloscope. Both will be connected to the TI C6713 on line-
line-out connectors. Frequency of Carrier Signal is fixed at 15 kHz while the message signal is varried from t
function generator. Since DSK C6713 ensures realtime simulation, once the message signal is varied we willoscilloscope that modulated signal is also varying. Lets discuss different steps involved.
http://2.bp.blogspot.com/_becES0hCzzM/TCWOSJrqUcI/AAAAAAAAAm4/n5eggFcnJWo/s1600/block_diagram_c6713.JPG8/12/2019 c6713with Matlab User Manual1
8/49
8/12/2019 c6713with Matlab User Manual1
9/49
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
8/12/2019 c6713with Matlab User Manual1
10/49
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: ccsdspcc = 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 thebackground.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.
8/12/2019 c6713with Matlab User Manual1
11/49
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
8/12/2019 c6713with Matlab User Manual1
12/49
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 continuevisible(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: displaydisplay(cc)
CCSDSP Object:
Processor type : TMS320C6713
Processor name : CPU_1
Running? : No
8/12/2019 c6713with Matlab User Manual1
13/49
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, isrunninglinkinfo = 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
8/12/2019 c6713with Matlab User Manual1
14/49
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: ''
8/12/2019 c6713with Matlab User Manual1
15/49
8/12/2019 c6713with Matlab User Manual1
16/49
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
8/12/2019 c6713with Matlab User Manual1
17/49
8/12/2019 c6713with Matlab User Manual1
18/49
EdGate Technologies V1.0
Page 18
12.Press any key to continue: halt,reset,reload,run,readddat_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)
8/12/2019 c6713with Matlab User Manual1
19/49
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
8/12/2019 c6713with Matlab User Manual1
20/49
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, runrestart(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'
8/12/2019 c6713with Matlab User Manual1
21/49
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, writecvar = 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
8/12/2019 c6713with Matlab User Manual1
22/49
8/12/2019 c6713with Matlab User Manual1
23/49
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
8/12/2019 c6713with Matlab User Manual1
24/49
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: getmembercvar = 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
8/12/2019 c6713with Matlab User Manual1
25/49
8/12/2019 c6713with Matlab User Manual1
26/49
EdGate Technologies V1.0
Page 26
18.Press any key to continuecstring = 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
8/12/2019 c6713with Matlab User Manual1
27/49
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 continueFinally, 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, clearFinally, 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
8/12/2019 c6713with Matlab User Manual1
28/49
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. ****************
8/12/2019 c6713with Matlab User Manual1
29/49
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 installed2) hardware connection
I. connect a c6713 DSK board to the pc through USBII. connect +5v power supply to the board
III. run the diagnostics3) configure ccstudio according to your external target board4) close down the ccstudio window5) open up the matlab window6) Type the following comments to make sure that correct board is selected and link is
made with ccstudio and matlab
a)ccsboardinfo
8/12/2019 c6713with Matlab User Manual1
30/49
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
8/12/2019 c6713with Matlab User Manual1
31/49
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 verificationtype c6000lib on comments window of matlab
8/12/2019 c6713with Matlab User Manual1
32/49
8/12/2019 c6713with Matlab User Manual1
33/49
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
8/12/2019 c6713with Matlab User Manual1
34/49
8/12/2019 c6713with Matlab User Manual1
35/49
EdGate Technologies V1.0
Page 35
Target reference block
8) click on simulink icon on matlab window to open simulink librarybrowser
8/12/2019 c6713with Matlab User Manual1
36/49
EdGate Technologies V1.0
Page 36
9) click on target for ti c6000c6000 target references
8/12/2019 c6713with Matlab User Manual1
37/49
EdGate Technologies V1.0
Page 37
10) To create new model FILenewmodel or click on below shonicon
11) Select c6713dsk drag and place in the new modelwindow(untitled)
Click on yes
8/12/2019 c6713with Matlab User Manual1
38/49
EdGate Technologies V1.0
Page 38
12)Similarly drag and place all the required block on new model windowAs shown bellow
Fig simple audio loop back
13)
Make all neccessory interconnection between the blocks
8/12/2019 c6713with Matlab User Manual1
39/49
EdGate Technologies V1.0
Page 39
14) Save the model:filesave (give any name with .mdlextension)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
8/12/2019 c6713with Matlab User Manual1
40/49
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)
8/12/2019 c6713with Matlab User Manual1
41/49
EdGate Technologies V1.0
Page 41
Memory /section
Use default memory (no change required in below window)
8/12/2019 c6713with Matlab User Manual1
42/49
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 wantIf 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
8/12/2019 c6713with Matlab User Manual1
43/49
8/12/2019 c6713with Matlab User Manual1
44/49
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 Applyok16) Click on save icon on model window
8/12/2019 c6713with Matlab User Manual1
45/49
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
8/12/2019 c6713with Matlab User Manual1
46/49
8/12/2019 c6713with Matlab User Manual1
47/49
8/12/2019 c6713with Matlab User Manual1
48/49
8/12/2019 c6713with Matlab User Manual1
49/49
EdGate Technologies V1.0
20) Hardware connection