This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

two seperate call stacks with MSP and PSP

Hello,

I intended to implement an application without OS. Due to safety concerns I would like to have two call stacks : one for softdevice using MSP and the other for my application using PSP.

Is there an example for how to do this ?

Regards,

Parents
  • Hi telemedcar, Like butch said, compiler takes care of this stuff and thinking about this is normally done by people implementing an Operating system. That said, it is quite simple to select stack pointer for an application. Exception handlers always use MSP. So if the application is making SVC call or for any application peripheral specific IRQs, only MSP will be used. For thread mode you can control which stack pointer to use by writing to Control Register. If you initialize the control register quite early in your application, then when exception occur (softdevice always run in exception handlers) proper EXEC_RETURN will be pushed to the stack to mark that when it returns to thread mode then it should pop stack pointer value to PSP . Look at table 2.17. One you have selected PSP in control register and initialized it proper value at the start of the application, then compilers and ARM core will handle the rest.

Reply
  • Hi telemedcar, Like butch said, compiler takes care of this stuff and thinking about this is normally done by people implementing an Operating system. That said, it is quite simple to select stack pointer for an application. Exception handlers always use MSP. So if the application is making SVC call or for any application peripheral specific IRQs, only MSP will be used. For thread mode you can control which stack pointer to use by writing to Control Register. If you initialize the control register quite early in your application, then when exception occur (softdevice always run in exception handlers) proper EXEC_RETURN will be pushed to the stack to mark that when it returns to thread mode then it should pop stack pointer value to PSP . Look at table 2.17. One you have selected PSP in control register and initialized it proper value at the start of the application, then compilers and ARM core will handle the rest.

Children
Related