This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How and when to use separate stack pointers in a non-RTOS application?

Hi,

We are developing a safety critical product based on Cortex-M4 CPU. In the Definitive Guide for ARM Cortex-M3/4 I read that it is recommended to use both (MSP and SPS) stacks even, if program does not use RTOS. By using both stacks, the program is supposed to be more robust. I also see in the book how this should be implemented in the startup file, but I don't understand in which cases these separate stacks would be more beneficial than just one stack (MSP).

I would be very grateful, if someone could explain this a little bit.

Best regards.

Parents
  • Let say there is an error where MPU violation triggers HardFault (writing to some RO address). In HardFault I would like to read a PC counter to locate this fault. With a single stack (MSP only) this works great. Will this work also with separate stacks?

    Second, let say that I have separate stacks (PSP for program, MSP for interrupts and exceptions). For somewhat reason PSP overflow occurs during program and at the bottom of the stack it hits a protected region (by MPU). This also triggers HardFault. Am I able to recognize there what went wrong? Even if MPU violation occurred before all 8 registers were pushed to the stack?

    Thank you

Reply
  • Let say there is an error where MPU violation triggers HardFault (writing to some RO address). In HardFault I would like to read a PC counter to locate this fault. With a single stack (MSP only) this works great. Will this work also with separate stacks?

    Second, let say that I have separate stacks (PSP for program, MSP for interrupts and exceptions). For somewhat reason PSP overflow occurs during program and at the bottom of the stack it hits a protected region (by MPU). This also triggers HardFault. Am I able to recognize there what went wrong? Even if MPU violation occurred before all 8 registers were pushed to the stack?

    Thank you

Children