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


xQueueReceive Wait Time, and Return Value

Posted by groger57 on June 20, 2017

Hello, So I now have various tasks using a queue to send data, and a receive queue to send to the UART. It seems to work OK, but wants to hang up somewhere. It's a touch screen app - for example, the clock stops updating, and if I touch a "hot spot" on the screen that generates a message, all of a sudden the receive queue starts to respond and spew out all the messages that are apparently backed up. I have a queue size of 35. This is the receive function.

void QueueRxFunction( void *pvParameters ) { BaseTypet xStatus; QueueHandlet xQueue;

xQueue = (QueueHandle_t) pvParameters;

    //value of 1500 seems to work 
    xStatus = xQueueReceive( xQueue, &uartMssg, 1500 );                

    if( xStatus == pdPASS )
        UBaseType_t spaces = uxQueueSpacesAvailable( xQueue );
        if( spaces == 1 )  assert(QUEUE_LOW_SPACE);
        uint8_t chkErr = SCRNCOM_GetResponse( uartMssg.message ); 
        if( chkErr != RCVD_PROMPT ) assert(UART_ERR1);
        printf("Couldn't queue message: %s\n", uartMssg.message);



The function SCRNCOMGetResponse is basically a UART send and then poll for response: SCRNCOMGetResponse( char s) { while(s) { //while transmit buffer is not empty.... while( USARTGetFlagStatus(USART2, USARTFLAGTXE ) == RESET); USARTSendData(USART2, *s++); }

while(1) // poll response
    //wait for data: USART_FLAG_RXNE will be reset
    while( USART_GetFlagStatus( USART2, USART_FLAG_RXNE) == RESET ); 
    rxCode = USART_ReceiveData( USART2 ); 

    if( rxCode == RCVD_PROMPT )
        //one more for 0xD (end of message)
        while( USART_GetFlagStatus( USART2, USART_FLAG_RXNE) == RESET ); 
        rxCode = USART_ReceiveData( USART2 );                         

return rxCode; }

If I reduce the value of xQueueReceive's wait to about 1200 or lower, I start to get the messaging printing and the assert handler going. With a UART baud of 115,200 it is hard to imagine the UART backing up and the receive queue having to wait 1-1/2 seconds. There's just not that many messages and formatting strings being sent out.

Every place I send to the queue, looks like this: xQueueSend(mssgQueue, (void*)&xMssg, portMAX_DELAY);

Should I be using a similar number of ticks to wait there too?

I also have the configCHECKFORSTACK_OVERFLOW defined, and the task to catch the error. It never lands there.


xQueueReceive Wait Time, and Return Value

Posted by rtel on June 20, 2017

Have you tried using FreeRTOS+Trace to view how your application is running? I suspect it is getting 'stuck' somewhere you don't expect.

[ 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