Thank you, I also suffered from it in another project, it cost me a lot to get it to work correctly.
This project works by time, let me explain.
There is a main routine that runs every 10ms, this routine takes 2ms to run.
There is another routine that is executed every 12ms, it is an RS485 communication to different elements. This routine takes less than 2.8ms to execute.
There is another SPI communication routine with the TFT and the remote control, this routine is executed every 250ms, display refresh time
There are two other communication turns that work alternately, every 7ms
and finally there is a continuously running main loop that checks the limits and flags of the rest of the routines. This main routine runs about 45,000 times per second and is where the system is refreshed so it is never in a loop.
My opinion is increasingly focused on how the compiler treats SELECT CASE instructions and the resources it uses for it. It's the only thing that comes to my mind at the moment.
çNow the program has been running for more than 3:30:00 without stopping and the only thing I did was change many SELECT CASE statements to IF THEN. So this confirms my hypothesis.
I attach an analysis of the communication lines of the program so that it can be seen that it works in a non-synchronous way.
Thank you very much for the help
and see if I locate the error in a patient way.