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.

Header files

Other Parts Discussed in Thread: MSP430F2003

Some examples show the header file msp430.h while others use io430.h.  Is one preferred over the other?

  • msp430.h will drag in a group of msp430*.h files which define a set of words. io430.h will drag in a group of io430*.h file which define another set of words. Some member of the two sets are identical, some are similar but not identical, while some other members are very different. You can use one of the two sets, but not both of them. It is up to you which set of words you want to use and hence which header fill you include.

  • Hi Mark,

    i would prefer to use the msp430.h since it is compatible across the most common compilers for MSP430 such as IAR, CCS, and MSPGCC.

  • Mark Vojta1 said:
    Is one preferred over the other?

    msp430.h is available in Code Composer Studioand IAR Embedded Workbench.

    io430.h is available for IAR Embedded Workbench only. Compared to msp430.h it includes some IAR extensions, such as bit fields for hardware registers.

    These are the "generic" include files which then include the device specific header file according to the target device selected in the project.

  • I want to add that the use of bitfields, which is the main differenc ebetween the two 'sets' of header files, is ineffective for hardware registers and may also introduce some side-effects that are part of the way how bitfields have to be handled on one side and how hardware registers have to be handled on the other side. So while they appear convenient, their use is not recommended.

    besides this, teh use of the generic 'msp430.h' or 'io430.h' headers instead of the direct inclusion of the specific header files (msp430x*.h) obfuscates the target of the code. It might be useful if the code is 100% portable across all MSPs, but in the very most cases, code written for one MSP won't run on another one even though both might have the same modules and therefore no compiler error is thrown.

    incluing the specific header will show right at the beginning of the source code for which MSP this code was intended. OTOH it might compile without errors if forcefully compiled for a different target but including the header file for the other one.

    Best would be usign the generic include together with an explicit target check like
    #if _target != __MSP430F2003
    #error this code is for MSP430F2003 only
    (just a quick draw, the names might be different)

    But nobody does that, unfortunately. It would have saved lots of trouble with published demo code

  • i use a header file msp430.h in my programm as slave und others use io430.h. as master for i2c interface is that at all possible?

  • IO430.h and MSP430.h are two different sets of heade rfiles. However, their main content is the same.
    The io430.h IIRC provided bit structures for registers (not recommended to be used, for various reasons) and some of the 'internal' defines have different names.
    However, the key elements, the register names and bit defines, are (or at least should be) identical and match the names in the users guide.
    So if one project (slave) use the one, and another project (master) uses the other, there is no problem. The resulting binaries do not care from which header files the were generated.
    However, using MSP430.h is recommended. Also, always use the header file set that come siwht the compiler version you use, as the header files work together with the linker scripts and the compiler engine. (so update your linker scripts in your projects when updating the compiler)