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


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