NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

Accessing Variables and Macros in RTSC projects

From Texas Instruments Wiki
Jump to: navigation, search

The steps below show how to define environment variables and access them within RTSC configuration files and C source files.

1) Define an environment variable under Project Properties->Build->Environment.

This example shows a variable named MYREALSTRING with the value HelloWorld.

Env var1.png

2) To access this variable in RTSC .cfg, .c and .h files, define a Java property under Project Properties->Build->XDCtools->Advanced Options->Java properties by clicking on the Add button.

This example defines two Java properties:
BUILDDIR=${PROJECT_BUILD_DIR} - this references the CCS system variable PROJECT_BUILD_DIR that points to the project build directory
MYSTRING=${MYREALSTRING} - this references the environment variable created in step 1

Java define.png

3) In the RTSC .cfg script add the following lines (for each variable). The first line reads that variable and the second one makes it available to .c and .h files. The empty string at the end of the second line is there just to fix some type incompatibilities between JavaScript and Java strings.

This example shows the lines added for both variables BUILDDIR and MYSTRING. There are also some additional/optional print lines added for testing purposes.

var build_dir = environment["BUILDDIR"];
Program.global.build_dir = build_dir + "";

var mystring = environment["MYSTRING"];
Program.global.mystring = mystring + "";

print( "*******************************************" );
print( "build_dir = '" + environment["BUILDDIR"] + "'" );
print( "*******************************************" );

4) In the C files and header files where you need to access the variable, add the following line to include the header file <xdc/cfg/global.h>

# include <xdc/cfg/global.h>

You can then access the variable within the C code, for example:

    System_printf("%s\n", build_dir);
    System_printf("%s\n", mystring);

5) If you need to make the variable accessible in a linker command file, it should also be defined in the --define option under Project Properties->Build->Linker->Advanced Options->Command File Preprocessing.

E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Accessing Variables and Macros in RTSC projects here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Accessing Variables and Macros in RTSC projects here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article Accessing Variables and Macros in RTSC projects here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article Accessing Variables and Macros in RTSC projects here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article Accessing Variables and Macros in RTSC projects here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Accessing Variables and Macros in RTSC projects here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Accessing Variables and Macros in RTSC projects here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article Accessing Variables and Macros in RTSC projects here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Accessing Variables and Macros in RTSC projects here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity