Skip to main content
Explorer II
March 26, 2024
Question

Clarify stack management on STM32H7 / cortex M7

  • March 26, 2024
  • 1 reply
  • 946 views

Hello,

I'm a bit confused about stack management on Cortex M7.

In my SW I only use the MSP.

I understood that the MSP can only be modified with a MSR instruction. However the SP can be modified with a "simple" LDR instruction.

Does that mean that when I do a ldr sp, =xxx (with CONTROL.SPSEL = 0) it modifies not only the SP register but also the MSP register ?

Since I use only MSP, is there a difference between setting the SP with a LDR and setting the MSP with a MSR ?

    This topic has been closed for replies.

    1 reply

    Super User
    March 26, 2024

    Instruction ldr sp .... relates to the current SP, whatever it is msp or psp.

    If you are sure that the active SP is msp, no need to use msr.