Hi, I am using a NXP S32K118 Cortex M0+ processor
I have a scheduler function used to call different tasks ( all is time scheduled ) and i need to do the following:
-> Use the main stack pointer (MSP) for this scheduler function
-> Use the process stack pointer (PSP) for the scheduled tasks
I have 3 stacks defined in ram ( main stack, secondary stack 1, secondary stack 2 ). The idea is that the scheduler uses the main stack, and the scheduled tasks use the secondary stack 1 or secondary stack 2, so i need to switch from MSP to PSP when i´m in the scheduer, before calling the corresponding task, and switch back from PSP to MSP once the corresponding task is completed and im back on the scheduler.
I know how to switch these pointers writing to PSP/MSP/CONTROL registers, but the problem I have is i dont know how to do this context switch/ what i need to do in addition of simply changing stack pointers in order to keep all the stacks working properly, so im here just finding for any help/tips if anyone knows how to implement this properly.
Thank you! :)
Check out: The definitive guide to arm cortex-m3 and cortex-m4.
View all questions in Cortex-M / M-Profile forum