FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [August 2017 Threads] xQueueSendFromISR about V850Posted by focusfeel on August 23, 2017 I create a queue for data transmission between UART interrupt handler and a task, send data by xQueueSendFromISR function in UART interrupt handler function and receive data by xQueueReceive function in the task. In the task, when there is no data received, I set the xQueueReceive function wait forever, so the task is also blocked by the queue when there is no data received. As I expected, when data is sent in the UART interrupt handler by xQueueSendFromISR successfully, the task will be waken up. Is this right? If so, the task will go to running state. But the real result is that I find the data is received by the task by checking the memory, but the task is not go to run, still blocked by the queue. Why?
xQueueSendFromISR about V850Posted by heinbali01 on August 23, 2017 Let me guess, is your code like the following?
~~~
void UARTIRQHandler()
{
BaseTypet xHigherPriorityTaskWoken = pdFALSE;
uint8_t ch;
ch = uart_receive();
xQueueSendFromISR( xTxBufferQueue, &ch, ( BaseType_t * ) &xHigherPriorityTaskWoken );
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}
void myTask( void *pvParameter )
{
uint8_t ch;
for( ;; )
{
if( xQueueReceive( xTimerQueue, &ch, portMAX_DELAY ) != pdFAIL )
{
printf( "Received '%c'\n", ch );
}
}
}
~~~
The task will spend most of it's time in xQueueReceive() . The test for pdFAIL is not really necessary in case the time-out equals portMAX_DELAY .
Note that portMAX_DELAY is a symbolic value, it is not 0xffffffff or 0xffff ticks. It means: "for ever", or until success.
If your code is different, would you mind showing some of your code, both the UART interrupt handler as well as the task.
xQueueSendFromISR about V850Posted by focusfeel on August 24, 2017 My code is like to these, but in "xQueueSendFromISR( xTxBufferQueue, &ch, ( BaseTypet * ) &xHigherPriorityTaskWoken );" and "if( xQueueReceive( xTimerQueue, &ch, portMAXDELAY ) != pdFAIL )" there should be the same queue. I check the memory to know the data has send to the queue successfully, but why the xQueueReceive function does not return a "pdPASS"?
xQueueSendFromISR about V850Posted by heinbali01 on August 24, 2017 As you can see, I copy-pasted some code lines into my post. The names of the queues should be the same of course:
~~~
xQueueSendFromISR( xUartQueue, &ch, ( BaseType_t * ) &xHigherPriorityTaskWoken );
xQueueReceive( xUartQueue, &ch, portMAX_DELAY ) != pdFAIL )
~~~
Could you show your code, including the creation of the queue and task?
xQueueSendFromISR about V850Posted by focusfeel on August 24, 2017 My code is as bellow:
~~~
QueueHandlet SerQHandle;
uint8t rxdata8;
/* Create queue. */
SerQHandle = xQueueCreate(16, sizeof(uint8_t));
if (NULL == SerQHandle)
{
while (1)
{}
}
/* Create task. */
if (pdPASS != xTaskCreate(SerTask, "SerTask", 256, NULL, 2, NULL))
{
while (1)
{}
}
pragma vector = INTRLIN32UR1_vector
_interrupt void uart2interruptreceive(void)
{
portBASETYPE xHigherPriorityTaskWoken;
/* Have not woken a task at the start of the ISR. */
xHigherPriorityTaskWoken = pdFALSE;
/* Get received data. */
rxdata8 = RLN32LURDR;
/* Send received data to the queue. */
xQueueSendFromISR(SerQHandle, &rxdata8, (BaseTypet *)&xHigherPriorityTaskWoken);
portYIELDFROM_ISR(xHigherPriorityTaskWoken);
}
void SerTask(void *pvParameters)
{
uint8_t u8Data;
while (1)
{
if (pdPASS == xQueueReceive(SerQHandle, &u8Data, portMAX_DELAY))
{
/* Process data. */
...
}
}
}
~~~
If the task will be waken up when data is written to the queue successfully? Why my test result is the "xQueueReceive" cannot return a "pdPASS" even the data is send to the queue successfully?
xQueueSendFromISR about V850Posted by heinbali01 on August 25, 2017
If the task will be woken up when data is written to the queue successfully?
That is what I would expect. Your code looks perfectly sane.
Why my test result is the "xQueueReceive" cannot return a "pdPASS"
even the data is send to the queue successfully?
Which is strange.
Did you also call vTaskStartScheduler() to start the scheduler?
Is SerTask() the only task in this demo?
Can you confirm that SerTask() really gets started?
Are you sure that uart2_interrupt_receive() gets called?
Note that portBASE_TYPE is a less-used define ( typedef ) for BaseType_t .
Experiment: can your replace portMAX_DELAY with some reasonable value, like:
~~~
pdMSTOTICKS( 1000u );
~~~
When using that value, the function xQueueReceive() will return every second with pdFAIL . Can you verify if that happens?
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|