I have a project with an STM32F446, with RTX, 3 threads (main + 2 declared by me) + of course the idle one. The main thread enters wait state after starting the two threads so i have just two threads running. The RTX has round robin disabled. What the application does is talk to a a Bluetooth module over SPI.
My problem is that sometimes, during the SPI transfer (initiated by one thread and done in the other)the MCU crashes into the UsageFault_Handler and one of the threads (not always the same) is shown to overflow. Now I have read about how to debug the hardfaults and what nots but the problem is that all of the methods rely on MSP/PSP addresses and for me the PSP is 0x00000020. Anyone ever confronted with something similar? Any ideas on what might be wrong?
LE: I have since learned that the code works with FreeRTOS and not RTX. The code uses critical sections. I have tried using the same implementation for the critical section for RTX as for FreeRTOS(BASEPRI) but I often end up in UsageFault. I know that RTX uses extensively the SVC in the code.
Could it be that the Critical sections should be implemented differently ? Do you know of any other differences between FreeRTOS and RTX that could cause problems?
Later Edit(Solved): it turns out that the problem was related to the priority assigned to the SysTick. It was first set up to the lowest priority as it should but, a piece of code, somewhere was setting the SysTick to a very high priority.
Thank you!