Hi,
I just started my first freeRTOS project, but I have some behavior I can’t solve. In my task I alternately call a read and a write function. Both should wait/block until an special interrupt occurs. On first call I create a binary semaphore (one per function, read as an example):
~~~~~~
:::c
if (NULL == ReadSyncObj) {
if (NULL == (ReadSyncObj = xSemaphoreCreateBinary())) {
return (RES_NOTRDY);
}
xSemaphoreTake(ReadSyncObj, 10 );
}
~~~~~~
The interrupt handler is shared for both:
~~~~~~
:::c
static void _ISRHandler() {
status = GetIntStatus();
xHigherPTaskWokenRead = pdFALSE;
xHigherPTaskWokenWrite = pdFALSE;
if (status & READ_READY) {
ClearInterrupt(READ_READY);
(void)xSemaphoreGiveFromISR(ReadSyncObj, &xHigherPTaskWokenRead);
portYIELD_FROM_ISR(xHigherPTaskWokenRead);
return;
}
if (status & WRITE_READY) {
ClearInterrupt(WRITE_READY);
(void)xSemaphoreGiveFromISR(WriteSyncObj, &xHigherPTaskWokenWrite);
portYIELD_FROM_ISR(xHigherPTaskWokenWrite);
return;
}
}
~~~~~~
In the read and write functions I have the transfer started and the I take the semaphore:
~~~~~~
:::c
startReadOperation();
//fprintf(stdout, "r1rn");
(void)xSemaphoreTake(ReadSyncObj, portMAX_DELAY);
//fprintf(stdout, "r2rn");
~~~~~~
My problem is, that I can’t get past the xSemaphoreTake very often and never leave the idle task again. This behavior never occurrs if the fprintf functions are used, everything is working fine then.
My task has a priority of one and should meet the
~~~~~~
:::c
define configMAXSYSCALLINTERRUPT_PRIORITY ( 1 << 5 )
~~~~~~
requirement.
I am grateful for any suggestion
Jon