NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on The site is now set to read only.

Code Composer Watch Window: Using a Script to Populate

From Texas Instruments Wiki
Jump to: navigation, search


In Code Composer Studio 3.3 gel files were often used to easily populate the watch window with a defined set of variables. In Code Composer Studio 4 this is not possible by using gel files. In general, CCS 4 uses a workspace to save and restore a particular debug environment.

It may be desirable, however, to provide a simple script that will populate the watch window. This is helpful for collections of examples where it is not practical to supply a workspace that corresponds to each example.

This article explains how a JavaScript file can be used to populate the watch window. This has the advantage of being small and easily shared with other developers.

Note: CCS 4 and CCS 5

Code Composer Studio 4 uses java 1.4 while CCS 5.x uses java 1.6. The javascript parser is different between these two versions. In particular, the later java version enforces stricter syntax requirement. For this reason some scripts that worked under CCS 4 may fail under CCS 5.

Please refer for javascript syntax for function calls.

Step 1: Create the JavaScript script file

JavaScript can be used to quickly add a defined set of variables to the Code Composer Studio 4 watch window.

This example script uses the expAdd JavaScript function to add structures and variables to the watch window. The format of the display of each variable can also be specified by using getHex, getDecimal, getBinary, getFloat, getNatural, and getQValue.

<syntaxhighlight lang='javascript'> // // CCS V5 // my_watch.js // // expAdd ("CpuTimer0" ); expAdd ("CpuTimer1" ); expAdd ("CpuTimer2" ); expAdd ("CpuTimer1.InterruptCount" ); expAdd ("CpuTimer1.InterruptCount" ); expAdd ("CpuTimer1.InterruptCount" ); </syntaxhighlight>

Note: In CCS V4 the syntax was somewhat relaxed and the following script would have worked. Notice in the CCS 5 version, the ()'s around each function call and the ; after each function. Also notice that you can no longer set the view format programatically [1]

<syntaxhighlight lang='javascript'> // // CCS V4 // my_watch.js // // expAdd "CpuTimer0" getNatural() expAdd "CpuTimer1" getNatural() expAdd "CpuTimer2" getNatural() expAdd "CpuTimer1.InterruptCount" getDecimal() expAdd "CpuTimer1.InterruptCount" getHex() expAdd "CpuTimer1.InterruptCount" getNatural() </syntaxhighlight>

Step 2: Open the Code Composer Studio scripting console

In Code Composer Studio, open the scripting console by using the view->scripting console menu

Step 3: Run the script

Click on the "Open Command File" at the top right of the scripting console.


Navigate to the script you wrote in step 1 and select "open" The script will now run and populate the watch window.


The result is the following watch window.


Other commands

In the scripting console window you can type commands as well.

  • To get help on a particular command type help and the command: js:> help expAdd
  • To get a list of all commands type help followed by a tab.