FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [June 2017 Threads]
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!
Have you tried using FreeRTOS+Trace to view how your application is
running? I suspect it is getting 'stuck' somewhere you don't expect.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.