zohargolan365 wrote on Tuesday, March 22, 2016:
HI all,
I have a problem with xSemaphoreTake() in FreeRTOS 8.2.0 (and 8.2.3) port for Freescale Kinetis (using Mcu on Eclipse component).
The problem is that I have an interrupt with priority 8 which is giving a binary semaphore
/*
** ===================================================================
** Event : EInt1_OnInterrupt (module Events)
**
** Component : EInt1 [ExtInt_LDD]
/
/!
** @brief
** This event is called when an active signal edge/level has
** occurred.
** @param
** UserDataPtr - Pointer to RTOS device
** data structure pointer.
/
/ ===================================================================*/
void EInt1_OnInterrupt(LDD_TUserData UserDataPtr)
{
/ Write your code here … */
uint32_t error;
portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
// Set semaphore
error = xSemaphoreGiveFromISR(MySemaphore, &higherPriorityTaskWoken);
// Activate the task immediately if priority is higher
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
}
Then I have a task with priority 8 which is taking the semaphore
for (;
{
if(xSemaphoreTake(MySemaphore, (TickType_t) 20) != pdTRUE)
{
ThreadSafePrintf("Missed an interrupt.\n");
}
else
{
function();
vTaskDelay(5);
}
}
The configMAX_SYSCALL_INTERRUPT_PRIORITY is set to (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY<<(8-configPRIO_BITS)) where configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITYis set to 5
This mechanism is working fine for long time (anywhere from 10 minutes to several hours) and then the function stops executing.
if I am printing the tasks state (using vTaskList), I see that the task is in running stste. The external interrupt is keep running correctly and when the semaphore is given, the result of the xSemaphoreGiveFromIsr is false.
The RTOS will get from this weird state only if I will run a higher priority task (priority 9) which has a vTaskDelay(1) in it. Once the vTaskDelay(1) is executed, the scheduler is switching back to the stuck task and execution proceed as normally.
Please advise as I am desperate
Best regards,
Z