vagni wrote on Monday, September 28, 2009:
I am using FreeRTOS v4.6.1 on my STR75x-based application with IAR EW-ARM v4.41A.
I have an UART-ISR with the following code:
static PDU_STRUCT RxBuf;
static xQueueHandle xQueueRxPdu; // a queue capable of containing pointers to PDU_STRUCT structures
__arm void UART1_Isr(void)
{
portBASE_TYPE xTaskWokenByPost = pdFALSE;
PDU_STRUCT *pRxBuf = &RxBuf;
if( Received_Valid_PDU )
{
// post the received PDU
xTaskWokenByPost = xQueueSendFromISR( xQueueRxPdu, (void *)&pRxBuf, xTaskWokenByPost );
}
/* If a task was woken by a message being received
then we may need to switch to another task. */
portEND_SWITCHING_ISR( xTaskWokenByPost );
}
Then I have one my task with the following code:
// coda della PDU ricevuta
static xQueueHandle xQueueRxPdu;
void UartTask( void *pvParameters )
{
portTickType xLastWakeTime,xNextWakeTime;
PDU_STRUCT *pRxPdu;
// Create a queue capable of containing 2 pointers to PDU_STRUCT structures.
xQueueRxPdu = xQueueCreate( 2, sizeof( PDU_STRUCT * ) );
// task loop
for( ; ; Wdog() )
{
// wait for a message
xLastWakeTime = xTaskGetTickCount();
xNextWakeTime = xLastWakeTime + 200;
if( QueueReceive( xQueueRxPdu, &pRxPdu, xNextWakeTime ) == pdTRUE )
{
// received message processing
}
else
{
// do something else
}
}
}
So my task waits for a received message for max 200 ticks (200 msec), then does something else and returns to wait for a received message. Both the message processing time and the alternative processing time are less than 1 msec.
There is an external unit sending a message every 200 msec.
The above task has priority 2, the same of two other my task. Also there is another task with priority 3.
After some minutes or some hours or some days of continuous properly working (this is random time) my task suddenly stops receiving messages from the external unit. I can recover the issue only with an application reset.
What happens if xQueueSendFromISR() and portEND_SWITCHING_ISR() are called when my task is just running and not waiting for a message from the queue? In this case, when my task returns to call xQueueReceive() is it assured to find in the queue the message queued before by the UART_ISR?
Thank you for your help.