Hi,
My function and/or call to the queue task is crashing, and I cannot understand why. I am using the same, identical code in other applications and it works fine there. I checked the FreeRTOS config file, and all looks OK, including stack size. This is being compiled in Atollic TrueStudio. Please see below for how I am using the calls.
I have tried queueing messages from different tasks, but the same result. The task I am currently calling it from cycles every 225ms, and if there’s a new message to send, it places it (or tries to) on the queue. From the debug code, it never reaches there, as it appears to crash somewhere between the start of the scheduler and before queueing the message. I have also set the queue delay to some other value, i.e., ( TickType_t ) 10, but no luck there. It must be crashing before it even gets to the first call to queue, because it never prints the message just before it – see code.
FreeRTOS version 8.2.0
Can someone please advise as to where the issue might be? I really need this to work, and I can’t beleive that it is not functioning as it should – again, having used it in other applications I know it works very well.
Thank you!
//message task will wait forever for queue to clear
define rxQueueRATE ( portMAX_DELAY )
static void vTxQueueFunction( void *pvParameters );
QueueHandle_t xQueueTask;
//create transmit queue
xQueueTask = xQueueCreate( 1, sizeof(uint8_t) );
if(xQueueTask == 0)
printf("Failed to create xQueueTaskn");
if( xTaskCreate( vTxQueueFunction, "rxDataQueue", 80, NULL, 2, &xQueueTask ) != pdPASS )
printf("Cannot create queue taskn");
printf("Scheduler starting, free heap size = %in", xPortGetFreeHeapSize());
vTaskStartScheduler();
while(1)
{
i++;
}
///* queue function *////
static void vTxQueueFunction( void *pvParameters )
{
uint8_t rxValue;
portBASE_TYPE xStatus;
for(;;)
{
if( uxQueueMessagesWaiting( xQueueTask ) != 0 )
{
///printf(“Queue should be empty, but %i messages in queuen”, uxQueueMessagesWaiting( xQueueTask ) );
}
xStatus = xQueueReceive( xQueueTask, &rxValue, rxQueueRATE );
if( xStatus == pdPASS )
{
printf("Rcvd in signal active queue: %in", rxValue);
if( rxValue == 1 )
{
//do this
printf("Received 1 in message queuen");
}
else if(rxValue == 2)
{
//do that
printf("Received 2 in message queuen");
}
else
{
printf("received junkn");
}
}
else
{
printf("Could not receive from queuen");
}
}
}
/* the call to queue a message */
uint8_t typeVal = 1;
printf(“Going to queuen”);
if( xQueueSendToBack(xQueueTask, &typeVal, rxQueueRATE ) != pdPASS )
{
printf(“Failed to insert to queuen”);
}
else
{
printf(“Queuedn”);
}