Hi All,
I have a problem with the MCU On eclipse freeRtos component.
I am using k20fx512 device with the MCU On Eclipse component on KDS 3.0.0.
the freeRtos version is v8.2.0.
I have a periodic hardware interrupt which is pulsing every ~20 ms. This interrupt is giving a semaphore using
xSemaphoreGiveFromIsr
In the back end I have a task which is waiting for this semaphore in a for loop.
for (;;)
if(xSemaphoreTake(SemaphoreName, (TickType_t) 25) != pdTRUE)
"Missed a frame interrupt.\n");
else
...
task body
This mechanism is working perfectly until something happens and the task is not processing the task body anymore.
The interrupt is still working and when the semaphore is given in the ISR, it is returning an error, because it is already given.
the semaphore take just missed and the semaphore is still waiting endlessly.
Please advise
Zohar
Hi Zohar:
Please refer to the following example to use xSempaphoreGiveFromISR()
void vISR(void *pvParameters)
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
/*The event has occurr3d, use teh semaphore to unblock the task so the task can process the event*/
xSemaphoreGiveFromISR(xSemaphore, &HigherPriorityTaskWoken);
/* Clear the interrupt here */
/* */
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
/*Define a task that performs an action each time an interrupt occurs. */
void vATask(void * pvParameters)
{
/*it is assumed the semaphore has already been created outside of this task*/
for (;;)
{
/*wait for the next event*/
if ( xSemaphoreTake(xSemaphore, portMAX_DELAY) == pdTURE)
/* The event has occurred, process it here*/
......
/*Processing is complete, return to wait for the next event*/
}
}
Regards
Daniel
Thank you Daniel,
This is exactly how I am using the interrupt
Zohar