Quality RTOS & Embedded Software

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


Queue Handling

Posted by Chandra V on July 1, 2009

I am using freeRTOS for my development. I have two doubts and if anybody knows the information please share it.


I am using Queue mechanism for receiving RS232 serial port bytes from external devices with 9600 Baud rate.

My task is working fine when "xTicksToWait" is assigned to 0 with Queue API:

Ex: "if( xQueueReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 0 ) )"

But my task is not at all executed after few cycles, if i use "xTicksToWait" as 1.

Ex: if( xQueueReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 1 ) )

If you know possible reasons please let me know.


How to use "Legacy Trace Utility"?

I have configured configUSE_TRACE_FACILITY to 1 as mentioned in website and ran the system. Where "trace buffer " will be stored(ie. which folder in PC) and when it will be stored?

How to do the conversion by using tracecon.exe?


RE: Queue Handling

Posted by Richard on July 2, 2009
The most likely reason is the tick interrupt is not executing. If there is no tick then time does not progress, and if time does not progress then the block time never expires.


RE: Queue Handling

Posted by Chandra V on July 2, 2009
Hello Richard,

Thanks for your reply. Tick is executing fine.

I got a break through during debugging. Both cases are working fine when i commented following piece of code in my UART RX ISR.

"if( xHigherPriorityTaskWoken )
/* Actual macro used here is port specific. */

But, i don't know how these piece of code is linked with below mentioned issue. Currently, looking for rootcause....


RE: Queue Handling

Posted by Richard on July 2, 2009
Which port (processor and compiler) are you using? Did you check the example ISRs to see if you syntax matches?


RE: Queue Handling

Posted by Chandra V on July 3, 2009
Hello Richard,

Sorry. I have mentioned wrong syntax in my previous post and correct one is given below:

"if( xHigherPriorityTaskWoken )
/* Actual macro used here is port specific. */
portYIELD_FROM_ISR( HighPrioTskWoken );

My testsetup config details are:

Microcontroller : V850
Port code : port.c, portasm.s85 (provided by freeRTOS)
Compiler : IAR
freeRTOS version : 5.2.0


RE: Queue Handling

Posted by captnskydiver on July 8, 2009
I have also had problems with taskYIELD (implemented as portYield()) and timeouts in queuesend/receive routines. I think it might be related to FreeRTOS port I use. RTOS version is 5.2.0 and it is PIC18F port.

Only thing that actually yields processor time and does task switching is vTaskDelay in my case. At least it seems so.

I was looking a little bit into source code and it looks like vTaskDelay's fiddling with event lists and what not somehow makes scheduler actually switch tasks when vTaskSwitchContext is called from taskYIELD as compared to just simply calling taskYIELD.

I'm not sure but it looks like I will have to go into digging through FreeRTOS source after weeks of fighting with phantom bugs in my project.

RE: Queue Handling

Posted by Richard Damon on July 8, 2009
Note that taskYield() will only switch to a task with same or higher priority (and higher only if preemption is turned off or some ISR didn't run the scheduler when it needed, as otherwise they would have been running already) as the task is still marked "Ready" so if it is still the highest priority task that is ready it will still run. taskDelay makes the current task "Not Ready" so lower priority tasks can execute.

RE: Queue Handling

Posted by captnskydiver on July 31, 2009
Ahaaaa! Now that explains a lot of things! Thanks...

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

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

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

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

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


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers





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