M4 port stack corruption

Here are few ideas to start off with:

  1. Are you sure your interrupt can complete in the shorter time allotted when the rate increases to 500Hz (would have thought so, but worth asking).

  2. The Cortex-M ports re-use the stack that was allocated to the main() function as the interrupt stack once the scheduler has been started. That means the size of the interrupt stack is set by your project’s linker options, so the kernel has no [easy] way of knowing if it overflows. If you faster interrupt rate is resulting in more nested interrupts then it is possible you are using more interrupt stack, resulting in overflows that are not present with the lower interrupt frequency.

  3. Also read through the usual suspects here: https://www.freertos.org/FAQHelp.html (it sounds like you already have, but point it out all the same) - in particular ensure to be using a recent version of FreeRTOS with configASSERT() defined as the newer the version the more assert() there are to check the software configuration matches the hardware configuration.

  4. Ensure the compiler options correctly describe the floating point unit present on your hardware - they are not all the same.