在STM32官方论坛里提问了:
https://community.st.com/s/question/0D50X00009sW72oSAC/how-to-debug-a-hard-fault-exception-for-stm32
Finally, after I have changed the task stack size of the new added OSPF task from 500 to 2000, everything goes fine. However, I still cannot figure out how could task stack overflow cause the above strange phenomenon.
Or just as this link (https://www.micrium.com/detecting-stack-overflows-part-1-of-2/) says:
Stack overflows are common and can lead to some curious behaviors. In fact, whenever someone mentions that his or her application behaves “strangely,” insufficient stack size is the first thing that comes to mind.
Although I am using a FreeRTOS operating system, my knowledge about os is very limited. It's time to make up this limitation for me.
cnblogs上一个中文的关于STM32堆栈的讲解,非常好