Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

xQueueSendFromISR about V850

Posted 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 V850

Posted 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 V850

Posted 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 V850

Posted 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 V850

Posted 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 V850

Posted 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?


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner