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.

MSP432 - Why does the initial stack pointer starts at 0x20004000 ?

Hi everyone,


The startup file provided by TI setups the initial stack pointer at 0x20004000. I am wondering why it is not placed at the start of the RAM region which address is 0x20000000.. As the stack pointer goes upward I guess this makes us wasting 0x4000 bytes of RAM (16K), and therefore only use 0xC000 bytes. It is enough for me but it looks weird..

/* Interrupt vector table.  Note that the proper constructs must be placed on this to */
/* ensure that it ends up at physical address 0x0000.0000 or at the start of          */
/* the program if located at a start address other than 0.                            */
void (* const interruptVectors[])(void) __attribute__ ((section (".intvecs"))) =
{
    (void (*)(void))((uint32_t)0x20004000), /* The initial stack pointer */
    resetISR, /* The reset handler */
    ...
};

Thank you for helping me to understand this point (:

Best regards,

  • As the stack pointer goes upward ...

    Where have you heard that ?

    Check again, and the question will be answered.

    Besides of specific TI documents, I can recommend http://infocenter.arm.com/help/index.jsp as source for information about the Cortex M cores in general.

  • "upward" usually means the direction against gravity. Is gravity involved here?
    If not, my upward can be your downward. (This has nothing to do with the fact that I am Chinese.)
  • I just assumed "upward" to mean "increasing numbers" or "increasing addresses". If attach a unit (like meter or yard), and assume the number to be a radius, you can get gravity into the picture ...

    If not, my upward can be your downward. (This has nothing to do with the fact that I am Chinese.)

    Since I am sitting in Europe, our vectors of "strongest gravity pull" might actually point into opposite directions, 3D-wise ...

  • Ok, my bad, the address decrease as the stack gets filled. So starting from 0x20004000 will makes us only use 0x4000 bytes for the stack.
    There are two questions now:
    - Why is the initial stack pointer setup at 0x20004000 ?
    - Why don't we set the initial stack pointer to 0x20010000 instead to use all the RAM region ; What the rest is used for/by ?
  • Lets consider g > 0, g is always directed to the center of the earth. If you guys in china have g in the other direction (with g still > 0), you would be pushed away from the surface unless you have something that makes you counter the gravity by exerting a higher force in the opposite direction.. ?! (;
  • I am looking in CCS and see the use of __STACK_END, which is placed at 0x20010000.  I will dig into this and see if I can find a history.

    #pragma DATA_SECTION(interruptVectors, ".intvecs")
    void (* const interruptVectors[])(void) =
    {
    (void (*)(void))((uint32_t)&__STACK_END),
    /* The initial stack pointer */
    resetISR, /* The reset handler */
    nmiISR, /* The NMI handler */

    000003b5 SystemInit
    4000480c WDTCTL_SYM
    20010000 __STACK_END
    00000200 __STACK_SIZE
    000009ec __TI_CINIT_Base

  • All,
    I hope this provides a little bit of clarity. By setting the stack to 0x2000 4000 this means that the stack will only reside in Bank 1 and Bank 0 depending upon the size. With the MSP432 you could turn off banks 2 through 7 and maintain the stack. Additionally you can configure certain banks to retain information during LPM3 and LPM4. Setting the stack to 0x2001 0000 means that all of the stack is enabled (Bank0 through 7) since you cannot have 'holes' and Bank0 is always enabled and retained.

    This is further described in the TRM in the System Controller section: www.ti.com/.../slau356d.pdf

    Regards,
    Chris
  • Thank you Chris, I better understand now.

    Best regards
  • Many thank to Cris. Good that the question is answered now!

    === clearly OT ===
    Here is something totally different about UPWARDS.

    In the old days, there was a terminal called Teletyp-33 that was top-heavy. To ship it, they put it in a wooden crate. And to prevent the crate from tipping over easily, they put the heavy end of Teletype at the bottom of the crate. On the outside of the crate, they painted an arrow pointing to the light end with the words THIS SIDE UP.

    They received a lot of complains, such as: "You marked the crate incorrectly; the Teletype was shipped UPSIDE DOWN."

    To clear the confusion, below the original THIS SIDE UP, they added the words THIS EQUIPMENT MUST BE SHIPPED UP SIDE DOWN.

    No more confusion as what is UP and what is DOWN. Right?

**Attention** This is a public forum