Skip to main content
Gpeti
Senior
Mar 26, 2024 9:57 AM UTC
Question

Clarify stack management on STM32H7 / cortex M7

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

Pavel A.
Mar 26, 2024 1:48 PM UTC

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.