cancel
Showing results for 
Search instead for 
Did you mean: 

Clarify stack management on STM32H7 / cortex M7

Gpeti
Senior II

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 ?

1 REPLY 1
Pavel A.
Evangelist III

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.