My project runs in total 13 different threads and the task facing the issue is the one with highest priority.
I am running a Freertos version 8.0.1 on Atmel SAMG55G19 microcontroller.
There is a xSemaphoreTake on my button task (task with highest priority) with a blocking period of 2 seconds. Once in a while Freertos tends to not unblock, even after the expiry of 2 seconds, the semaphore take leading to a frozen thread. I have already investigated and confirmed that no other task is interfering with this task by faulty interrupts or lengthy critical sections.
The issue is sporadic in nature and its frequency of occurrence is once or twice in a day.
The normal way of detecting this is to define configASSERT() (you will
see a link to that on the page linked above), but you are using quite an
old version of FreeRTOS and I’m not sure how many asserts it contains.
I would recommend updating the FreeRTOS version to get better error
detection.
I trying to porting freeRtos 7.3 to 9.0 for samG55 in my application.
earlier i was using xTaskResumeFromISR() and vTaskSuspend() for task synchronize which was doing pretty well for my application but interrupt was less often. But later I found there are chances of missing, if interrupt rates are high and xSemaphoreGiveFromISR/xSemaphoreTake is solution for this.
While porting i faced the same issue has above. the semaphore take thread being into block state.
Looks this related to interrupt priority. I have macro in FreeRTOSConfig.h which i didnt understood.
But later I found there are chances of missing, if
interrupt rates are high and xSemaphoreGiveFromISR/xSemaphoreTake is
solution for this.
If you are using FreeRTOS V9.0.0 then it is actually better to use task
notifications as they are smaller and faster than semaphores. See the
example on the following page: http://www.freertos.org/vTaskNotifyGiveFromISR.html
define configPRIO_BITS 2
I doubt that is correct as I’ve never seen a processor of this class
only having 2 priority bits. Have a look in the hardware manual for the
G55 part to find the number of priority bits that are actually
implemented. It is likely to be between 3 and 5 inclusive.