fraza077 wrote on Tuesday, November 12, 2013:
Microcontroller: PSoC 5LP
Compiler: ARM GCC 4.7.3
FreeRTOS version: FreeRTOS V7.5.2
I’ve used FreeRTOS successfully on this architecture for a while now, but I’ve run into this problem with queues.
I have a queue, set up by
MainRxQueue = xQueueCreate(configMAIN_RX_QUEUE_LENGTH, 1); // where configMAIN_RX_QUEUE_LENGTH is 600
My main task is the only task that reads from this queue, and the only thing that writes to it is the UART ISR. The queue is not protected by a mutex.
The call from the ISR:
xQueueSendToBackFromISR(MainRxQueue,&dat,&xHigherPriorityTaskWoken);
The Task takes the characters off the queue here:
while(1)
{
test_var[0]++;
// receive remaining characters from queue
if (xQueueReceive(MainRxQueue, &singleChar, 500/portTICK_RATE_MS) == pdFAIL)
{
test_var[8]++;
text[cnt] = 0;
Uart_PutString(text);
return FALSE;
}
test_var[1]++;
...
This usually always works fine for a while (data received and processed), then it doesn’t return from xQueueReceive (my interpretation of test_var[0] being 1 greater than test_var[1] and test_var[8] being 0). I can’t work out what the trigger is.
So basically my code mostly sits in the idle task. Other tasks are still running fine. From the idle task, I run this code:
for(;;)
{
mystate = eTaskGetState(Main_ReturnTaskHandle());
myprio = uxTaskPriorityGet(Main_ReturnTaskHandle());
}
The state after this non-return error is always eReady. The priority is still 2.
I’ve ruled out:
– The queue being full or empty – I’ve observed the xQUEUE variable and it’s neither
– The queue handle being corrupted – it has the same value it has had since creation
There doesn’t seem to be any pattern to when it happens. Sometimes it happens the first few packets I send, sometimes it doesn’t happen at all.