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] [May 2015 Threads]
Instead of asking what's WRONG with my code, can someone please point me to an example, or provide an example, of the correct way to use xQueueSend from a module other than where the queue handle and function handler are defined?
I'm using FreeeRTOS 8.2.0, in IAR EWARM 7.3, on an STM32F4 controller. I am unable to find an example on the entire web that shows this, and it just happens to be giving me a big headache right now.
Thank you...
It shouldn't make any difference which module the queue handle is defined in. A queue handle is just a variable, so it can be declared in one C file, and then extern'ed in another C file, just like any other variable.
File1.c
/* Declared globally. */
QueueHandle_t xQueue = NULL;
int main( void )
{
. . .
xQueue = xQueueCreate( 5, sizeof( uint32_t ) );
. . .
/* Start tasks. */
. . .
/* Start scheduler. */
}
void vTask1InFile1( void *pvParameters )
{
uint32t DataToSend = 0, DataToReceive;
const TickTypet xBlockTime = pdMSTOTICKS( 200 );
for( ;; )
{
. . .
xQueueSend( xQueue, &DataToSend, xBlockTime );
. . .
xQueueReceive( xQueue, &DataToReceive, xBlockTime );
}
}
File2.c
void vTask2InFile2( void pvParameters )
{
/ Here the queue handle is extern. */
extern QueueHandle_t xQueue;
uint32t DataToSend = 0, DataToReceive;
const TickTypet xBlockTime = pdMSTOTICKS( 200 );
for( ;; )
{
. . .
xQueueSend( xQueue, &DataToSend, xBlockTime );
. . .
xQueueReceive( xQueue, &DataToReceive, xBlockTime );
}
}
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.