Showing results for 
Search instead for 
Did you mean: 

Why the TCP Thread halts the other thread?


Dear friend,

I've got two threads running on a STM32F107RCt6 MCU;

One is a Modbus TCP Server thread with the stack size of 256 words and the other is a Modbus RTU thread with the same stack size.

When there is no client connected to the Modbus tcp server, the RTU task works correctly and runs without any errors permanently but when a client is connected and reads/writes the Modbus registers, after 2 or 3 hours or more (less than 12 hours) , the Modbus RTU thread stops working in a way that you could say the TCP task terminates the Modbus RTU task.

Could any one help me to find out why this happens and after working hours, the RTU taks stops?

Is there any way to find out the current state of Modbus RTU task within the TCP task and if it was terminated, it restart it?

I am using the latest version of CubeMX and HAL drivers.

I use lwIP netconn APIs with freeRTOS and I config them on CubeMX.

The total heap size of freeRTOS is 10KB.

The priority of both tasks are the same.

The client is a Monitoring software application which connects to the MCU every 2.5 seconds and reads the Modbus registers.

And also I've declared every variables that theses two tasks require globally so I don't use any message or mail queues to send data between tasks. Can this cause a problem in a way that one task stops working after a while???

Any help would be appreciated,



Instrument your code so you know what's happening.

Make sure Hard Fault and Error Handler report useful information.

Identify and instrument any infinite loops, or cases where a deadlock or blocking might occur.

Make sure the SystemTick, or timing source driving HAL Ticks has the highest priority.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..