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.

cstartup.s43, is it really necessary?

Other Parts Discussed in Thread: MSP430F149

I am modifying firmware written for the MSP430F149 that was compiled and linked under IAR 1.26b... a very old version of the EW.  The firmware was written to include a custom cstartup.s43 assembly file.  Looking at the contents of this file, cstartup.s43, there is nothing in it that can't be done in the void main (void) function.  This file initializes the UDATA0, CDATA0, etc... and that is about it.  For the newer versions of IAR, is it necessary to use a cstartup.s43 file?

BTW, UDATA0 and IDATA0 are now called DATA16_Z and DATA16_ID

  • Hi Christian,

    You probably don't need it at all.  In modern versions of EW, the IAR version of cstartup does everything you need, and for anything it doesn't do, you can write a __low_level_init() function which executes just before initialized RAM is initialized in cstartup.

    One common use of __low_level_init is to disable the watchdog timer so that it doesn't expire before cstartup finishes writing the initialized data.  If you don't have a lot of initialized data, then disabling the watchdog timer can wait for main( ) or better yet not done at all.

    So if you use a newer version of EW, you can usually eliminate cstartup.s43 from the project.  If I were you I would look for anything out of the ordinary it might be doing for you and put that stuff at the beginning of main( ) or if necessary in __low_level_init( ).

    Jeff

  • Hi Christian,

    The newer IAR includes its own cstartup, which actually initializes the SP register, calls any custom initialization routines, and calls main. If you have any initialized globals, cstartup also initializes them to default values. Basically it does what the name says it does, setting up the C "runtime" environment before actually executing main.

    If you wish to manage everything manually, you can of course choose not to link with the runtime library, and write your own initialization routines.

    Tony

  • Thank you both for the reply,

    Great!  I will place all of the initialization code from the cstartup.s43 file in the MAIN function of my new code.  I looked into the _low_level_init() function and I will keep that on the back burner in case I need to perform some special event prior to the program start.  Great suggestions!!

    Christian

**Attention** This is a public forum