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] [October 2016 Threads]
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?
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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.