Understanding traceQUEUE_RECEIVE and how it receives data

RTOSFree V8 on PIC32MX795F512L Ethernet Development Board Harmony 1.07.01 I opened the freertos basic project in harmony It compiles and runs on the Ethernet development board Main.c calls SYSTasks() SYSTasks function is in the SystemTasks.c file xTaskCreate function creates a list of tasks and then vTaskStartScheduler() is called. One of the tasks created is _APP2Tasks and this function is also in the SystemTasks.c file. _APP2Tasks calls APP2Tasks in the app2.c file The APP2Tasks calls a macro xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY ); The xQueueReceive macro is in the queue.h file ~~~

define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE )

~~~ As you can see it calls another macro xQueueGenericReceive The implementation of the macro xQueueGenericReceive is in the queue.c file ~~~ BaseTypet xQueueGenericReceive( QueueHandlet xQueue, void * const pvBuffer, TickTypet xTicksToWait, const BaseTypet xJustPeeking ) { BaseTypet xEntryTimeSet = pdFALSE; TimeOutt xTimeOut; int8t *pcOriginalReadPosition; Queuet * const pxQueue = ( Queue_t * ) xQueue;
configASSERT( pxQueue );
configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
{
    configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
}
#endif

/* This function relaxes the coding standard somewhat to allow return
statements within the function itself.  This is done in the interest
of execution time efficiency. */

for( ;; )
{
    taskENTER_CRITICAL();
    {
        /* Is there data in the queue now?  To be running the calling task
        must be the highest priority task wanting to access the queue. */
        if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )
        {
            /* Remember the read position in case the queue is only being
            peeked. */
            pcOriginalReadPosition = pxQueue->u.pcReadFrom;

            prvCopyDataFromQueue( pxQueue, pvBuffer );

            if( xJustPeeking == pdFALSE )
            {
                traceQUEUERECEIVE( pxQueue );

                /* Actually removing data, not just peeking. */
                --( pxQueue->uxMessagesWaiting );
~~~ As I understand the operation of the RTOS Basic project from Microchip; is that the tasks that have been started are constantly querying the UART for specific values. I am assuming that somewhere else in the program there is a section of code that generates a specific UART output at specific intervals. Toward the end of the section of code above appears to be the last leg of the code (traceQUEUERECEIVE( pxQueue );) that actually reads the value from the UART but I lose track of the code at this point. I have searched for traceQUEUE_RECEIVE in my project and there is only one other place that it shows up and it is the definition of the macro in the FreeRTOS.h file. ~~~

ifndef traceQUEUE_RECEIVE

#define traceQUEUE_RECEIVE( pxQueue )

endif

~~~ My goal is to understand how the pvBuffer variable in the xQueueReceive macro gets filled. I have my own board that is similar to the Ethernet Development board but instead of filling it with UART information I want have one task get filled with I2C information and another task get filled with SPI information. Any help or direction would be greatly appreciated.

Understanding traceQUEUE_RECEIVE and how it receives data

Unfortunately we are not able to provide support for other peoples applications, or how they structure them, only for FreeRTOS usage itself. traceQUEUERECEIVE( pxQueue ) is a trace macro that, by default, does nothing. It is provided to allow user code to be added into the RTOS code without having to modify the code. The reason it is called a trace macro is because it is normally used to generate trace output for tools such as FreeRTOS+Trace. While it is possible that Microchip would define traceQUEUERECEIVE() to read values from a UART, I would find that very unlikely, so I think you must be mistaken. As the queue is read using a function called xQueueReceive(), to find where the queue is written to you need to be searching for a function called xQueueSend(), which could well be in a UART interrupt service routine, in which case xQueueSendFromISR() would be called. http://www.freertos.org/Embedded-RTOS-Queues.html http://www.freertos.org/a00117.html http://www.freertos.org/a00119.html

Understanding traceQUEUE_RECEIVE and how it receives data

Can you tell me how the xQueueReceive() macro works – especially the second variable ulValReceived – how does it get filled?

Understanding traceQUEUE_RECEIVE and how it receives data

BTW – thank you for such a quick response on the last question.

Understanding traceQUEUE_RECEIVE and how it receives data

define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE )

The second variable is actually pvBuffer

Understanding traceQUEUE_RECEIVE and how it receives data

Can you tell me how the xQueueReceive() macro works – especially the second variable ulValReceived – how does it get filled?
Did you look at the source code, and step through it in a debugger? You can see data gets copied into it using a call to memcpy().

Understanding traceQUEUE_RECEIVE and how it receives data

Thanks – you were extremely helpful. I did run through the debugger but I was looking in the wrong area – again thanks for your help.