Just to make sure. You changed the Heap allocation to 4K or 6K using:
You get a runtime error not a compile/linker error. Are you using FreeRTOS with dynamic memory allocations?
I way to help debug where in the code there might be an issue is when you break in the IntDefaultHandler ISR look at the Call stack. This is the debugger's best guess where you have been in the code because these are the PC values stored on the stack during a call or interrupt.
Sometimes I remember getting into this IntDefaultHandler when I was using FreeRTOS and didn't allocate enough stack for the task. I used the Call Stack recommendation above to find the offending task and allocate more stack during the task initialization call.
Another suggestion is to reduce your memory requirements used by your application. I noticed you are using 92.3% of available RAM. Wow! Temporarily commenting out a high RAM use function might prevent the IntDefaultHandler issue,
Let me know if any of the above suggestions work out.
Optimized code will generally lower FLASH and RAM requirements unless optimized for speed.
Try my debugging suggestion with the Call Stack.
If that doesn't work, you may have to share your project.
Nothing looks obvious however check your code for the following:
- uint8 *rxdata points to an array of at least two bytes. If you only have a variable with one byte the line dumping the incoming SPI data into rxdata will overwrite unknown data. This unknown data could be stack or other RAM with pointer information.
- You have a while statement that loops until at least one byte is available in the SPIM_1 Rx buffer. You might want to change the statement to: while(SPIM_1_GetRxBufferSize() <2); Since the next three statements are assuming that at least two bytes are being read from the SPI, you might want to make sure at least two bytes have been received. Your code only assumes one byte is available.
Hope this helps.