alejoseb / Modbus-STM32-HAL-FreeRTOS

Modbus TCP and RTU, Master and Slave for STM32 using Cube HAL and FreeRTOS
GNU Lesser General Public License v2.1
576 stars 191 forks source link

Compatibility with TouchGFX-Display #114

Closed FebsterVF closed 1 month ago

FebsterVF commented 1 month ago

Heyo!

I have created a project that uses TouchGFX functionality for a Display, running on a STM32H745-Discovery board.

Modbus TCP Slave works just fine and can run simultaniously with the TouchGFX_Task. Unfortunately this does not work with Modbus TCP Master.

The Modbus connection blocks the display refresh as soon as a connection is established and the display appears to be frozen.

I followed your example of STM32H747 TCP exactly, and as I mentioned, it works, but the display does not. I did not implement anything else, basically a new project with one button for testing on the display and I just added the library and set everything up.

For ETH and LwIP i follow this guide: https://community.st.com/t5/stm32-mcus/how-to-create-a-project-for-stm32h7-with-ethernet-and-lwip-stack/ta-p/49308#how-to-create-project-from-scratch

I tried placing the Modbus stuff into its own task and adjusted the task priority so the display should have the highest priority, but no luck.

So, I have to ask, is this supposed to work? Is this maybe a memory problem? Could this be a known issue? Is there a step that should be done for this to work?

Thanks a lot for your awesome library btw :)

FebsterVF commented 1 month ago

I was able to make it work by increasing the stack size of the TaskModbusMaster in Modbus.c, guess one of these tasks had a stack overflow? Changed it from 4 to 6...

`//Task Modbus Master //osThreadId_t myTaskModbusAHandle; const osThreadAttr_t myTaskModbusB_attributes = { .name = "TaskModbusMaster", .priority = (osPriority_t) osPriorityNormal, .stack_size = 128 * 6//4 };

const osThreadAttr_t myTaskModbusB_attributesTCP = { .name = "TaskModbusMaster", .priority = (osPriority_t) osPriorityNormal, .stack_size = 256 * 6//4 };`