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:

  1. To demonstrate the new functions, try the following functions.
  1. When you switch to viewing CCS IDE, you see that your program stopped at the breakpoint you inserted on line 64, and the program printed

    in the CCS IDE Stdout tab. Nothing prints in MATLAB.

  1. Before you restart your program (currently stopped at line 64) you can change some of the values in memory. Perform one of the procedures listed below based on your target processor.
  1. C5xxx processor family--Type the following functions to demonstrate the read and write functions.

    1. Type ddatv = read(cc,address(cc,'ddat'),'double',4).
    1. Type idatv = read(cc,address(cc,'idat'),'int16',4).
    1. You can change the values stored in ddat by typing write(cc,address(cc,'ddat'),double([pi 12.3 exp(-1)...
      sin(pi/4)]))
    1. To change idat, type
    1. Start the program running again by typing
    1. Type ddatv = read(cc,address(cc,'ddat'),'double',4).
    1. Check that the change to idatv occurred by typing
    1. Finally, use 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.

    1. Type ddatv = read(cc,address(cc,'ddat'),'double',4).
    1. Type idatv = read(cc,address(cc,'idat'),'int16',4).
    1. You can change the values stored in ddat by typing write(cc,address(cc,'ddat'),double([pi 12.3 exp(-1)...
      sin(pi/4)]))
    1. To change idat, type
    1. Now start the program running again by typing
    1. Type ddatv = read(cc,address(cc,'ddat'),'double',4).
    1. Check that the change to idatv occurred by typing
    1. Finally, use restart to reset the program counter for your program to the beginning. Type
  1. The MATLAB Link for Code Composer Studio offers two more functions for reading and writing data to your target. These functions let you read and write data to the processor registers: 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.
  1. C5xxx processor family--Most registers are memory-mapped and consequently are available using 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.

    1. To read the value stored in register PC, type
    1. To write a new value to the PC register, type
    1. Check the PC contains the value you wrote.

    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.

    1. Retrieve the value in register A0 and store it in a variable in your MATLAB workspace. Type
    1. Retrieve the value in register B2 as an unsigned binary integer, by typing
    1. Now, use regwrite to put the value in treg into register A2.

  Loading Files into CCS Working with Embedded Objects