Quality RTOS & Embedded Software

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


Loading

Queue Communication not working

Posted by rclub123 on October 4, 2016

Hi i am trying to send an array from one task to another task.. but it is not working. here is my pseudo code: ~~~ int main(void) { xQueue = xQueueCreate( 2, sizeof(unsigned int) ); if ((xTaskCreate(vTask0, (const char )"Task0", configMINIMALSTACKSIZE, NULL, tskIDLEPRIORITY+2, &xHandle) != pdPASS) || (xTaskCreate(vTask1, (const char *)"Task1", configMINIMALSTACKSIZE, NULL, tskIDLEPRIORITY+2, &xHandle1) != pdPASS)) { printf("xTaskCreate() failed to create a task.n"); } else { / Start scheduler */ printf("Starting scheduler.n"); vTaskStartScheduler(); } } ~~~

~~~ void vTask0(void *pvParameters) { TickTypet xNextWakeTime; unsigned int data[2]; uint16t samplecount = 0; const TickTypet xFrequency =10; xNextWakeTime = xTaskGetTickCount(); while(1) { if (xQueueReceive(xQueue, &data,(portTickType)2)) { printf("received = %d n", data[0]); printf("received1 = %d n", data[1]); } vTaskDelayUntil(&xNextWakeTime, xFrequency); } } ~~~ ~~~ void vTask1(void *pvParameters) { TickTypet xNextWakeTime; unsigned int data[2]; const TickType_t xFrequency = 10; xNextWakeTime = xTaskGetTickCount(); while(1) { data[0]=3; data[1]=4; xQueueSendToBack(xQueue, &data, 0); vTaskDelayUntil(&xNextWakeTime, xFrequency); } } ~~~ Sorry i am new to RTOS, i want to send both data[0] and [1] to another task.. if i change the priority it will receive some random number. can anyone tell me what mistake i have done?


Queue Communication not working

Posted by davedoors on October 4, 2016

xQueueCreate( 2, sizeof(unsigned int) );

This creates a queue where each space can hold 1 unsigned int, so

xQueueSendToBack(xQueue, &data, 0);

sends one unsigned int, not two. Plus you are sending the address of the array not the array contents. Change '&data' to just 'data' in both the xQueueReceive and xQueueSendToBack calls.


[ 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