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.

preprocessor

Other Parts Discussed in Thread: MSP430F5659, MSP430F2274

Hello

first- a quick thanks for all advice up until now. Project is going along nicely, all roadblocks you folks have helped me get passed.  Much thanks!

Two processor system.  Initially it was an 8051 Master with a MSP3000 family ( i think  maybe 2000 family) 

I am replacing hte 8051 with a  MSP430f5659

i have a compile file  - I dont know what to call it - who defines what compiles to run based on a macro type definition. 

I need an 

#if (defined __ ??__)

statement for the compiler I'm using - the IAR version 6.1 compiler, but I dont know how to specifically do that.  I have tried to look this up in the compiler users guide  - no luck.  tried google, a number of places, no luck.    

My boss wants this code to be compile-able with an old processor or new, so he wants this file to add the new option, which I'm making MASTER2.   So MASTER2 will the preprocessor directives for the MSP430f5659 so I will add an

#elif (defined __???__)
#define MASTER2

Anyone have any idea what the ??? will be, and can I discriminate between the old msp, I believe it's a 3000 family or so, and my msp 5000 family so it won't try to compile the wrong processor with the wrong compiler?   The slave processor uses an IAR compiler as well, but an older version.

thanks!
Dubs

The file currently being used read as listed below:

/*------------------*/
/*--- IAR MSP430 ---*/
/*------------------*/

#if (defined __ICC430__)
#define SLAVE

#include <msp430x44x.h>

#define codeconst(T) const T

...

#elif (defined __C51__)
#define MASTER

#undef FALSE // in Keil 8.09, the uPSD header file defines these!
#undef OFF // bad Keil for changing something like that
#undef TRUE

...

/*------------------*/
/*--- BORLAND C ---*/
/*------------------*/
#elif (defined __BORLANDC__)

#define xdata
#define idata

...

#else
#error "unknown compiler/target"
#endif

MSP430f5659

  • Hi,

    By default when you set a project to a particular MSP430 device in CCS or IAR, it creates a predefined symbol corresponding to that processor name. You'll see the generic header files like msp430.h (CCS) or io430.h (IAR) use exactly this to determine the correct device specific header to include. So you could go look in io430.h for an example of what you are trying to do.

    The symbol that the IDE already has defined for the device is literally the device part number. So for example, if you are using MSP430F5659 and the other device you might be building the same project for is an F2274, you would do something like:

    #if defined (__MSP430F5659__)

    ...

    #elif defined (__MSP430F2274__)

    ...

    #endif

    Whichever device you currently have selected in the project settings will automatically select the right code this way.

    Regards,

    Katie

  • In addition to Katie’s construct, I would suggest expanding it to

    #if defined(__MSP430F5659__)

    #elif defined(__MSP430F2274__)

    #else
    #error target processor not supported
    #endif

     This ensures that you’ll get an error right at this point if you try to compile for an unsupported target. If you don’t do this, it will compile past this point without any notice, and you’ll get errors later in the code due to missing definitions, and you don’t know why. Or, worse, it compiles and links but is missing vital initializations and the hardware won’t work as expected.

  • perfect!  works perfect!

    I can't thank you enough! 

**Attention** This is a public forum