Some examples show the header file msp430.h while others use io430.h. Is one preferred over the other?
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.
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.
msp430.h is available in Code Composer Studioand IAR Embedded Workbench.Mark Vojta1 said:Is one preferred over the other?
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