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.

TMS320F280039C: #ifdef directive in .cmd file

Part Number: TMS320F280039C
Other Parts Discussed in Thread: C2000WARE

Hi Champ,

I am asking for my customer.

In .c and .h file, user could use #ifdef to switch between the code configuration. 

How about in .cmd file ? I followed the way as defining the contents into different sections in EABI format by using #if defined(), while by this way, it doesn't work correctly (it should allocate .const into FLASH_BANK0_SEC10).

Would the expert kindly show the correct way to define #ifdef directive in .cmd file ?

Thanks and regards,

Johnny

  • Hi Johny,

    You should be able to map the .const section to either sec15 or sec10 based on the _FLASH variable. Please define the variable in c2000_compiler flags. (--define _FLASH).

    You can also use the following format and try - 

    #ifdef _FLASH

    .const  :> FLASH_BANK_SECT15
    #endif
    Thanks
    Aswin
  • Hi Aswin,

    In the beginning, I had thought that it should work as we thought. However, it doesn't. (using CCS12.5)

    Please define the variable in c2000_compiler flags. (--define _FLASH).

    Do you mean to define the variable at here ? 

    I tried to remove _FLASH from the predefined symbols, it is supposed to map the .const section to sec10. However, after rebuild project, in the memory allocation, the .const section was still allocated in sec15 as shown.  

    Besides, I also tried the suggested format as follows, it doesn't work either. 

    #ifdef _FLASH
    .const : > FLASH_BANK0_SEC15, ALIGN(8)
    #else
    .const : > FLASH_BANK0_SEC10, ALIGN(8)
    #endif

    Would you kindly duplicate this at your side too by using CCS12.5 ? Then, point out what is missing here or what is the correct way to ifdef in cmd ?

    Thanks and regards,

    Johnny 

  • Hi Johney,

    I have used the same changes in my linker cmd file- 

    #if defined(_FLASH)
    .const : > FLASH_BANK0_SEC15, ALIGN(8)
    #else
    .const : > FLASH_BANK0_SEC10, ALIGN(8)
    #endif

    Please have a look at the project properties->c2000linker option. If the _FLASH macro is defined in the linker flags, then it would be taking the SEC15, else it will take the SEC10.

    Please do the updation in these and see if you are still facing the issue.

    Thanks

    Aswin

  • Hi Aswin,

    Thanks for pointing out the place. As I define the variable in C2000 Linker (Advanced Options -- Command File Preprocessing – Pre-define preprocessor marco_name_to_value), the issue is solved.

    One more question about is there a way to define the symbol for .c/.h file and .cmd file at the same time and at the same place ? Cause it seems like we separate the symbol which is in the c/.h file or in .cmd file. For the symbol defined in .c/.h file, it is defined in C2000 compiler, and for the symbol defined in .cmd file, it is defined in C2000 Linker.

    Customer is asking is there a way to just define symbol in one properties for all of the files (.c/.h/ linker file) ? I didn't see a place in the properties for such request, or this is what we do for separating those defined variables where it defined. Would you kindly check on this ?  

    Thanks and regards,

    Johnny

  • Hi Johnny,

    One approach that you can use is update the example projectspec. 

    In the projectspec you can define the compilerBuildOptions and linkerBuildOptions specified in the example.projectspec file located in the C2000Ware_5_01_00_00\driverlib\f28003x\examples\adc\CCS folder (i chose ADC for a reference).

    You can add the defines there.

    Thanks

    Aswin