Software time goes AMOK

I’m Using: FreeRTOS 7.3, MplabX 1.7, ICD 3, XC32 V1.2, PIC32MX795F512L, XP SP3. I’m using software timers to progress through a state machine by sending a message to a queue. I’m starting and stopping the timers at various stages. However, at one point, the timer does not stop when I use the xTimerStop and the period decreases. It never stops. It appears that the something to do with the timer is gone AWOL. I tried using the RTOSViewer but it shows nothing. There are two tasks running, one has a minimal stack size of 600 and the other 1200 bytes, which is the one running out of control with the timer. The total heap size is 28000. How can I get to the source of the problem? I have a feeling that something is being corrupted, stack, queue or whatever. Jastmc

Software time goes AMOK

Additional Info: In the task where the timer is running the uxTaskGetStackHighWaterMark() gives me 0x01DB, which seems like a good enough margin. Jastmc

Software time goes AMOK

Jastmc, I had problems with the timers going nuts as well. I believe there is a bug in the timer code in 7.3 and may have been fixed recently. In the meantime, try raising the priority of the timer task above that of your tasks.

Software time goes AMOK

Travfrog is correct that there was a corner case that could cause issues if the priority of the timer task was at or below the priority of tasks using the timers.  That would be the first thing to try – travfrog has already suggested the quick fix and test if the priority of your timer task is indeed below the priority of the tasks using timers (if you want the full fix that would allow you to keep the priorities unchanged then look at timers.c from FreeRTOS V7.4.0). If that does not fix your problem, or if your timer task is already above the priority of the tasks using the timers, then post back.  We will then need a little more information to help diagnose the cause. Regards.

Software time goes AMOK

Upgrade to 7.4 works perfectly! Thanks all.
James