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.

MSP430FR2355: In which file is #__STACK_END defined?

Part Number: MSP430FR2355


When I create a blank assembly file *.asm in CCS, the stack pointer SP is initialized to 0x3000h (the end of the data memory). So #__STACK_END must have been defined somewhere to be 0x3000h but I searched through the header files *.h in the Project Explorer's includes menu and couldn't find where #__STACK_END is defined.  Would someone help point out where it is?

RESET       mov.w   #__STACK_END,SP         ; Initialize stackpointer
StopWDT     mov.w   #WDTPW|WDTHOLD,&WDTCTL  ; Stop watchdog timer

  • The linker script describes the memory layout and defines symbols based on that.

  • Where is the linker script file that defines __STACK_END? The only place I can dig out this definition is in the xml file (*_linkInfo.xml) in the Debug output folder.  So the Linker Script is an XML file and I can modify the definition in this XML file? 

  • I use GCC so I have no idea where CCS hides its linker scripts. I think CCS uses a  .cmd extension so look for a msp430fr2355.cmd.

  • It's not in the msp430fr2355.cmd or lnk_msp430fr2355.cmd ... the Linker Command Files were among the first batch of files I searched.  I can locate all other symbols (e.g. SP, WDTPW, other peripherals address symbols) just not #__STACK_END.

  • I was also puzzled, since I thought I knew but I didn't find it in the Usual Suspect places.

    The assembler (and linker) book (SLAU131U) Sec 8.5.10.4 mentions "__TI_STACK_END" and says it "is assigned the end of the .stack section" (where the .stack section is defined in lnk_msp430fr2355.cmd).

    No this isn't an exact match but I bet fiddling with the .stack definition would make a difference.

    [Edit: When I removed the "(HIGH)" specification from .stack, __STACK_END moved to 0x2000.]

    [Edit: It appears that  __TI_STACK_END is in fact not defined by the linker, so I suppose this is a (legacy?) mistake in the book.]

  • I suspect __STACK_END is hidden perhaps somewhere in the assembler or compiler like __TI_COMPILER_VERSION__  

  • I suspect __STACK_END is generated by the  linker per SLAU131U Sec 8.5.10.4, based on its (computed) location of the .stack section. If you want to change it, fiddle with the ".stack" specification in lnk_msp430fr2355.cmd (project file). This isn't as easy as changing a constant, but it can be done. What change do you want to make?

    My guess is that (a) it was originally called __TI_STACK_END (b) the linker writers changed it to __STACK_END (c) no one told the document writers about the change [first time in history that's ever happened].

**Attention** This is a public forum