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.

CCS4: predefined value on CPU type

Other Parts Discussed in Thread: MSP430F2274, MSP430F5528, MSP430F5438

Hello,

I'm using CCS4 for several kinds of MSP430. Is there a way to query the CPU selected in project properties during compile time in order to make CPU specific code.

For example the MSP430F2274 needs a different Flash-PROM initialization as MSP430F5528. Erasing and writing is the same. Any kind of predefined value to use at #if defined(???) would help to compile code CPU specific.

I know IAR has such a feature, but has CCS it as well?

Regards

Guenther

  • Guenther,

    I am not a MSP expert, therefore I am not 100% sure what are the requirements for the Flash-PROM initialization of each device, but CCSv4 allows you to have multiple Build Configurations in a single CCSv4 project. Each Build Configuration has its own set of compiler and linker options and allows including/excluding files from being built for each configuration.

    Check the attached example project that is pre-configured for two different MSP devices - it has different compiler/linker options and includes and excludes the correct files for each device.

    Excluding files from each Active Build Configuration:

    http://e2e.ti.com/support/development_tools/code_composer_studio/f/81/p/56180/199409.aspx#199409

    Please note the example project uses completely different source files, but the C-source and the linker CMD files can be controlled using custom #define/#ifdef/#ifnded. Although the C syntax is straightforward, the linker allows #defines to control its memory placement as well. Please refer to the page below for details:

    http://processors.wiki.ti.com/index.php/Using_Preprocessor_Support_in_Linker

    Hope this helps,

    Rafael

     

    msp430_adc_graph.zip
  • Hello Rafael,

    Thank you for the hint but I'm already using this feature of separte files for projects. My desire was to have one source file for multiple processors. On IAR I could do it like:

      // Name: FlashWrite::Init()
      // Parameter: none
      //    return: 0 = okay, others fail
      // Descrption:
      //    Init (re)sets all parameters of the FlashWrite class
      short FlashWrite::Init()
      {
    #if defined(__msp430x54x)
    #else     
        if(Clock::TicksPerUSec > 1)
          FCTL2 = FWKEY + FSSEL0 +0x27;    // MCLK/40 for Flash Timing Generator
        else
          FCTL2 = FWKEY + FSSEL0;          // MCLK/1 for Flash Timing Generator   
    #endif     
        mp_BufferSegment = 0; 
        return 0;
      }

     

    or

        short* source = (short*) m_FlushBuffer;
        short* target = (short*) mp_BufferSegment;
    #if defined(__msp430x54x)
          __disable_interrupt();                    // 5xx Workaround: Disable global interrupt while erasing.
    #endif
     
        FCTL3 = FWKEY;                            // Clear Lock bit
        FCTL1 = FWKEY + ERASE;                    // Set Erase bit

     

    I hope this shows my intention. I'm looking for a solution in CCS.

    Regards

    Guenther

  • Guenther,

    All MSP430 device include files have a symbol defined that will help you achieve what you want.

    For example, if you open the header file <msp430f5438.h> you will find the following statements at the beginning of the file:

    #ifndef __msp430x54x
    #define __msp430x54x

    Is this what you are looking for?

    Cheers,

    Rafael

     

  • Hello Rafael,

    Thank you for the hint. However that is not wat I was looking for. The value __msp430x54x in above example resulted by my source code modification but not due to CPU selection for the build.

    The CCS4 requires to set the CPU type at project definition (see project properties > CCS Build > Device Variant). As far as I know these settings are used to select the right linker command file and most likely some other values; maybe a setting I can use in my source code.

    IAR as example defines a value like __MSP430F5438__ for the compiler pre-processor which is used in MSP430.h to include the correct device definition (as you correctly said in my example msp430f5438.h )

    So my question is: Does CCS has or will get a definition for the selected CPU to be used in source code as pre-processor command? Such a definition allows to write robust source code for multiple CPUs.

    Regards

    Guenther

  • Guenther,

    Now I get the idea. Unfortunately right now we do not have an automated way of defining the symbol straight from the CCS project wizard, but it is surely a useful point. We'll file an enhancement for CCSv4 and get back to you with its number.

    Best regards,

    Rafael

  • Guenther,

    The enhancement request SDSCM00037577 was filed yesterday. Please check its status at the SDOWP link below.

    Cheers,

    Rafael

  • Hello
    I checked with Lawrence Wong and this enhancement was added to the MSP430 family. I would like to ask the same enhancement to be added to other fanilies, in particular the CCS used by the Hercules family which I am currently using.
    The reference for the enhancement can be found at:

    http://archive.is/RFWLp under bug fixes:

    SDSCM00037577 Emulation 4.1.3 ALL Request for a predefined symbol to be passed from project wizard to compiler options for MSP430 devices

    Could you please help me?