stm32n6 (stack switching problem)
Dear all,
I'm encountering a strange issue with the STM32N657.
I have a very simple test application that successfully turns on an LED — everything works as expected.
Now, I need to switch the stack and enable the PSP. To do so, I’m using the following code:
uint8_t PSPstack[800] __attribute__((aligned(8)));
__set_PSP((uint32_t)(PSPstack + sizeof(PSPstack)));
__set_CONTROL(__get_CONTROL() | 0x2); // Set SPSEL = 1 to use PSP
__asm volatile ("isb");
However, as soon as I execute this code — specifically the line setting CONTROL to 0x2 — the system enters an exception (likely a fault handler), and execution stops.
Do you have any idea how to debug this or what could be going wrong?
Thanks in advance for your help.
Kind regards,
Edo
