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.

IAR systems predefined macros

Other Parts Discussed in Thread: MSP430F5172, MSP430F2131, MSP430G2553

I have successfully used #if defined __MSP430G2553__ and #if defined __MSP430F2131__ (and others). Now I want to conditionally compile the same code for MSP430F5172 but find that the symbol __MSP430F5172__ is not defined when I set the Project->Options->General options->Device to MSP430F5172. Any idea why not? Is there a list of predefined macros that go with the various processors? Is there a way to display the command line that is used to invoke the compiler?

  • Those defines (actually not macros, as they simply exist and do not have a content) are meant for internal usage. They are used to tell MSP430.h which header files it has to include. And perhaps to tell the compiler which errata workaround to use for this processor.
    It is possible that multiple MSPs require exactly the same header files (e.g. are identical except for the size of flash). So selecting any one of them  results in the same, more generic define.

    I guess, there is no “MSP430F5172.h” include file too.

  • If you want to use the same project to compile to multiple targets in IAR, then use the build configuration mechanism.

    By default these are Debug and Release, but you can define your own and name it anything (Project->Edit Configurations->New). When you select your custom configuration you can then set the properties.

    In the Project->Options for each configuration,  set the target processor. On the C/C++ Compiler settings, Preprocessor tab at the bottom, add a defined symbol, like TARGET_2553 for your 2553 build config, or TARGET_5172 for the F5172 configuration.

    Then, in your code, use #if defined(TARGET_5172) .... etc

  • These two replies both answer the question and how to do what I want. Thanks to both.

**Attention** This is a public forum