I have a relatively simple program with three tasks as follows:
-
A housekeeping thread
-
A GPIB thread
-
A serial thread
I can run the program for a long time (days under normal conditions) and then the GPIB stops working. Having put a load of debug code in, I can see it’s not crashing the processor. I have heartbeat LEDs in the housekeeping thread and the GPIB thead. The GPIB heatbeat LED stops while the housekeeping LED continues.
I don’t have exactly the same setup as the one that runs for days in a remote location, but today I managed to repeat the same symptoms by bombarding the GPIB with comms every 100ms and I was able to replicate the GPIB thread stopping.
I have the debugger attached and, but stopping and setting breakpoints I can see it’s never getting into the GPIB thread. The housekeeping thread is running fine. When it gets to the end of its infinite loop, the housekeeping thread calls vTaskDelay() with a delay of 100ms.
The serial task is fine. It just sits there until it gets a byte in over the serial port. If I send something into it, it does receive the serial data. However, no serial data is being sent into the unit, so really we only have two threads demanding processor time.
It’s just the GPIB task that stops getting called. It does use some pin change interrupts which send to a queue from interrupt. I am including in any pin interrupts:
if (pdTRUE == xHigherPriorityTaskWoken)
{
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
And my priorities for all these pin interrupts are set to 10 which is lower than the 5 set for configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY in the header file.
I have a massive stack size of 512 for the GPIB thread which cannot be consuming that much RAM, and the processor never crashes, so I do not think it’s a stack overflow. I will rerun and put some high watermark checking in just to be sure. However, whereas I’ve never had an issue like this in fuifteen years of using FreeRTOS, I have had many stack issues and they’ve all ended in hard fault interrupts. I am definitely not getting hard fault interrupts or crashes.
So, for the moment, before I set it running again; with the debugger connected and GPIB thread not getting any time from the scheduler, is there anything I can look at with the debugger (STM32 Cube IDE and JLink Basic) that might help me track this down.
Somewhere while ploughing through a shed load of posts on various places I think I saw a reference to a FreeRTOS aware plug in for Eclipse. Is that really available and if so, where could I find it please?
Maybe more importantly, with the task getting starved, the serial thread only going when it receives a serial byte in (which as things stand never happens) and the housekeeping thread - which is really only one of two threads that is taking any processing time - relinquishing control by calling vTaskDelay, does anyone have some tips for tracking down what is going on here please? Is there somewhere in the scheduler I can set a breakpoint to see why the scheduler doesn’t give the GPIB thread any time.
The GPIB thread itself has two xQueueReceive calls, one for if it is transmitting on to the GPIB bus and one for if it is receiving. Both of them time out, the GPIB thread should not be getting stuck anywhere. There are no while loops that do not have escape clauses.
I should probably also confirm the GPIB thread is running highest priority.
Many thanks.