This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Does the Code Composer Compiler automatically create a symbol which indicates which controller is used?
I have to set the Controller in the Project Properties of Code Composer Studio. So it should be possible that the compiler creates a symbol like the PART_LM<XXXXXX> symbols which is used in the StellarisWare.
I can set the symbol manually. But then I have to change it in two places which is not so nice.
Thanks and Regards
Markus
Markus Klein1 said:So it should be possible that the compiler creates a symbol like the PART_LM<XXXXXX> symbols which is used in the StellarisWare.
This symbol is not predefined by the compiler. It comes from the Stellarisware code. The list of symbol names predefined by the compiler are documented in the ARM Compiler Users Guide, section 2.6.1.
There is a variable predefined by CCS that might be of use. If you go into Project Properties->Build->Variables tab and check the box "Show system variables", you can see the list of system variables defined by CCS. I see that there is one called DEVICE which is set to the device selected during project creation.
Hello,
the DEVICE Variable seems to be what I'm looking for.
If I compile the code
#ifdef DEVICE
#warning Hello World
#endif
I get my "Hello World" warning when I compile with default options. But when I enable the GCC-Exensions (--gcc) the warning is gone. Any Idea?
The second problem is that the value of the DEVICE-Variable is defined as a string. With this it is not possible to do a comparison.
#if DEVICE == "LM3S…”
Thanks and Regards
Is it a string or an identifier? Does the value have quotes in it?
Try this:
/* We want to determine if DEVICE==abc or DEVICE==xyz */ #define _DV(x) DEV_##x #define DV(x) _DV(x) #define DEV_abc 1 #define DEV_xyz 2 #if (DV(DEVICE) == DEV_abc) #warn "It's abc" #elif (DV(DEVICE) == DEV_xyz) #warn "It's xyz" #else #warn "Something else" #endif armcl file.c -DDEVICE=xyz
AartiG said:There is a variable predefined by CCS that might be of use. If you go into Project Properties->Build->Variables tab and check the box "Show system variables", you can see the list of system variables defined by CCS. I see that there is one called DEVICE which is set to the device selected during project creation.
I probably should've provided a bit more detail in my previous answer, I apologize for not doing so the first time.
I see that this CCS system variable DEVICE is defined if a specific device is selected when a new project is created. I have noticed it is not set in some cases if a device like "Generic C64x+ Device" is selected instead of a specific part. In any case, you should be able to use it if it is defined under Project Properties->Build->Variables, Show System variables.
These variables can be used in compiler build options using the ${varname} syntax.
So for example, if DEVICE is defined as the string LM4F122H5QD, one way to use it would be:
- Under Compiler->Advanced Options->Predefined Symbols, add ${DEVICE} to the --define option
- this will resolve to the option --define=LM4F122H5QD being passed to the compiler (you can check this in the CCS build console)
- In your code, you can then write
#if defined(LM4F122H5QD)
which will only be true if that symbol is defined.
Hope this helps.