temazzz wrote on Monday, April 14, 2014:
Hello!
I have issue with Queue Set.
I use FreeRTOS 8.0.0, IAR 6.40, STM32F103RD
I have a task which is blocked by semaphore take.
This semaphore is given in ISRs. After semaphore is given
my task will run. It works ok.
But I also want to synchronize my task with queue to receive messages from another task.
To do it I create Queue Set which includes semaphore described above and queue.
But sometimes my task is blocked forever…
I tried to remove queue for messages from my QueueSet but I have the same behavior.
When my task is blocked forever uxMessagesWaiting in my semaphore is equal to 1 and uxMessagesWaiting for my QueueSet
is equal to 1 too. But task doesn’t transit in active state…
My code is similar with the following:
Status_t task_init(void)
{
mSignals = 0;
xQueueSet = xQueueCreateSet( SET_LENGTH );
if(xQueueSet == NULL)
{
return STAT_ERROR;
}
mSignalsSemaphore = xSemaphoreCreateBinary();
if(mSignalsSemaphore == NULL)
return STAT_ERROR;
if(xQueueAddToSet(mSignalsSemaphore, xQueueSet) != pdPASS)
return STAT_ERROR;
xSemaphoreGive(mSignalsSemaphore);
if(xTaskCreate(Task, "Task", configTASK_STACK_SIZE, NULL,
configTASK_PRIORITY, NULL)!= pdPASS)
{
return STAT_ERROR;
}
return STAT_OK;
}
void bttask_setSignalFromISR(bt_uint signal, signed portBASE_TYPE* higherPriorityTaskWoken)
{
unsigned portBASE_TYPE savedInterruptStatus;
savedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
mSignals |= signal;
portCLEAR_INTERRUPT_MASK_FROM_ISR(savedInterruptStatus);
xSemaphoreGiveFromISR(mSignalsSemaphore, higherPriorityTaskWoken);
}
static void Task(void* params)
{
bt_uint signals;
QueueSetMemberHandle_t xActivatedMember;
for (;;)
{
xActivatedMember = xQueueSelectFromSet( xQueueSet, portMAX_DELAY );
if(xActivatedMember == mSignalsSemaphore)
{
xSemaphoreTake(mSignalsSemaphore, 0);
taskENTER_CRITICAL();
signals = mSignals;
mSignals = 0;
taskEXIT_CRITICAL();
if (signals & BTTASK_SIG_RX)
{
bttask_pal_handleRxSignal();
}
if (signals & BTTASK_SIG_TX)
{
bttask_pal_handleTxSignal();
}
if (signals & BTTASK_SIG_TIMER)
{
bttask_pal_handleTimerSignal();
}
}
else
{
}
}
}
Best regards,
Artem Z