Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists