CPU component for ARM - stack setup issue?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CPU component for ARM - stack setup issue?

723 Views
bowerymarc
Contributor V

I noticed this while using the MKL04Z16VFK4 (ARM Cortex M0+) CPU component.  Under build options, you have a setting for stack size.

Well, tracing through a compiled running program, it looks like the stack settings are used to initialize the MSP (SP_MAIN) stack.  But... when running, the program seems to be using the PSP (SP_PROCESS) stack, which is initialized to a different memory area which is not noted anywhere or protected, and ends up smashing into various static variables.

So, what's the deal?  Should there be TWO stack settings (as, I believe, the MSP is used for ISRs?), or at least the MSP initialized somewhere protected?

Labels (1)
0 Kudos
1 Reply

425 Views
marek_neuzil
NXP Employee
NXP Employee

Hello,

The PSP stack can be used by the thread mode of the core. However, this requires a prior write the the CONTROL register, since by default the thread mode is using the MSP stack.

Processor Expert in bareboard configuration doesn't explicitly switch the thread mode to use PSP, so only MSP stack is used in the project.

The MQX lite OS does use the PSP stack, the initialization and handling is done in the source code of the MQXLite OS. Stack size for each task can be defined using Processor Expert  in the MQXLite component.

Best Regards,

Marek Neuzil

0 Kudos