Quality RTOS & Embedded Software

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


Loading

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;

for(;;)
{
    //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);
    }
    else
    {
        printf("Couldn't queue message: %s\n", uartMssg.message);
         assert(UART_ERR2);
    }

}

}

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 );                         
        break;
    } 
}

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.

Thanks!


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