Search code examples
stackfreertosstm32h7hardfault

What could happen if task stack size exceeded in freeRTOS mode of STM32, C


I am working with a project where I need to establish Ethernet connection in order to configure MQTT protocol. I am using FreeRTOS tasks and LwIP MQTT library. Although, while the program is running and MQTT subscriptions are appearing to the my screen, after a couple of minutes the screen gets frozen and doesn't response to anything unless I make a reset. I have to mention that I am using a Riverdi screen for my implementation STM32H7 microcontroller which has a default FreeRTOS task with stack size of 512 words (2048 bytes).

If the stack size is exceeded then is it possible to make my screen go to HardFault?


Solution

  • Yes, that's certainly possible. If the stack is too small, either other contents in memory will get overwritten (which would likely result in undefined behavior), or a non-existing memory address could get accessed (which would most likely result in a HardFault).