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.

Using CCS Variables in source code

From Texas Instruments Wiki
Jump to: navigation, search

This article shows how you can reference CCS build variables within symbol definitions in C source code and within project options.

This can be useful when you want to

  • define a variable in the source code and place it at a specific location in memory (generally useful for specifying version numbers, code revisions, etc) and
  • have the CCS build use that variable/string as part of the output file name

1) Write your C code:
Here is an example C code that places variables nv_data (float) and nv1_data (string) into specific memory locations using #pragma DATA_SECTION.
(Refer to the Compiler Users Guide if you are not familiar with the pragma).
This is simply a template meant to be used as a reference.
Note: the syntax for the string macro is a bit different (a reference on that is here).

#define xstr(s) str(s)
#define str(s) #s

#pragma DATA_SECTION(nv_data, ".infoD")
#pragma RETAIN(nv_data)
const float nv_data[] = {MYVERSION};

#pragma DATA_SECTION(nv1_data, ".infoC")
#pragma RETAIN(nv1_data)
const char nv1_data[] = {xstr(MYVERSION_STRING)};

2) Create CCS build variables:
Go to Project properties->Build->Variables tab and create build variables with the desired values

Ccs variables.png

3) Define compiler symbols that reference the variables:
Under Project properties->Compiler->Advanced Options->Predefined Symbols, add --defines to define the symbols used in the C code

Compiler defines.png

4) Use the variable in build options:
Under Project properties->Linker->Basic Options, for example, use the variable in the output file name. "${ProjName}_${STRING1}.out"

Linker options.png

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 Using CCS Variables in source code 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 Using CCS Variables in source code here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article Using CCS Variables in source code here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article Using CCS Variables in source code here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article Using CCS Variables in source code here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Using CCS Variables in source code here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Using CCS Variables in source code here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article Using CCS Variables in source code here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Using CCS Variables in source code 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