MATLAB Link for Code Composer Studio Development Tools | ![]() ![]() |
Working with Links and Data
With the target code loaded, you can use the MATLAB Link for Code Composer Studio functions to examine and modify data values in the processor.
When you look at the source file listing in the CCS IDE Project view window, there should be a file named ccstut.c.
The MATLAB Link for Code Composer Studio ships this file with the tutorial and includes it in the project. ccstut.c
has two global data arrays--ddat
and idat
. They are declared and initialized in lines 10 and 11 of the source code. You access these processor memory arrays from MATLAB using the functions read
and write
.
The MATLAB Link for Code Composer Studio provides three functions to control target execution--run
, halt
, and restart
. To demonstrate these commands, use CCS IDE to add a breakpoint to line 64 of cctut.c
. Line 64 is
For information about adding breakpoints to a file, refer to your Code Composer Studio User's Guide from Texas Instruments. Then proceed with the tutorial:
read
and write
functions.
Because you requested 16-bit integers, whose maximum value is 512, the values 647 and 7000 come back as zeros since they cannot be represented as 16-bit integers. Using int32
would have returned the full values for all the data in idatv
.
ddat
by typing
write(cc,address(cc,'ddat'),double([pi 12.3 exp(-1)...
sin(pi/4)]))
write(cc,address(cc,'idat'),int32([1:4]))
Here you write the data to the target as 32-bit integers (convenient for representing phone numbers, for example).
Checking the Stdout
tab in CCS IDE reveals that ddat
and idat
contain new values. Now we read those new values back into MATLAB.
restart
to reset the program counter for your program to the
beginning. Type
C6xxx processor family--Type the following commands to demonstrate the read
and write
functions.
Because you requested 16-bit integers, whose maximum value is 512, the values 647 and 7000 come back as zeros since they cannot be represented as 16-bit integers. Using int32
would have returned the full values for all the data in idatv
.
ddat
by typing
write(cc,address(cc,'ddat'),double([pi 12.3 exp(-1)...
sin(pi/4)]))
write(cc,address(cc,'idat'),int32([1:4]))
Here you write the data to the target as 32-bit integers (convenient for representing phone numbers, for example).
Checking the Stdout
tab in CCS IDE reveals that ddat
and idat
contain new values. Now read those new values back into MATLAB.
restart
to reset the program counter for your program to the
beginning. Type
regread
and regwrite
. They let you change variable values on the processor in real time. As before, the functions behave slightly differently depending on your target. Select the appropriate procedure for your target to demonstrate regread
and regwrite
.
read
and write
. However, the PC register is not memory mapped. To access this register, you use the special pair of functions--regread
and regwrite
. The following commands demonstrate how to use these functions to read and write to the PC register.
To tell MATLAB what datatype you are reading, the string binary
indicates that the PC register contains a value stored as an unsigned binary integer.
cc.regwrite('PC',hex2dec('100'),'binary')
This time, binary
as an input argument tells MATLAB to write the value to the target as an unsigned binary integer. Notice that you used hex2dec
to convert the hexadecimal string to decimal.
C6xxx processor family--regread
and regwrite
let you access the processor registers directly. Type the following functions to get data into and out of the A0 and B2 registers on your target.
![]() | Loading Files into CCS | Working with Embedded Objects | ![]() |