Quality RTOS & Embedded Software

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


Loading

Problem with 3 Tasks and 2 queue

Posted by Nobody/Anonymous on March 3, 2007
Hello!

I´m using Freertos some days ago.... And i want to create 3 tasks using 2 queue ... the definition of the tasks and queues are

pParamEvento1 = ( Param_evento * )pvPortMalloc( sizeof(Param_evento ) );
pParamEvento1->xQueueEvento = xQueueCreate(LONG_COLA,sizeof(xMessage));
pParamEvento1->xBlockTime = xDontBlock;
pParamEvento1->mensaje.ucMessageID=1;
pParamEvento1->mensaje.ucData=0;
pParamEvento1->DelayTime = ( portTickType ) 200 / portTICK_RATE_MS;

pParamEvento2 = ( Param_evento * )pvPortMalloc( sizeof(Param_evento ) );
pParamEvento2->xQueueEvento = xQueueCreate(LONG_COLA,sizeof(xMessage));
pParamEvento2->xBlockTime = xDontBlock;
pParamEvento2->mensaje.ucMessageID=1;
pParamEvento2->mensaje.ucData=0;
pParamEvento2->DelayTime = ( portTickType ) 200 / portTICK_RATE_MS;

sTaskCreate( Task_Ruedas, ( const portCHAR * const ) "Ruedas", portMINIMAL_STACK_SIZE, ( void * ) pParamEvento2,mainTASK_RUEDAS, NULL );
sTaskCreate( Task_Telemetro, ( const portCHAR * const ) "Telemetro", portMINIMAL_STACK_SIZE, ( void * ) pParamEvento2,mainTASK_TELEMETRO, NULL );
sTaskCreate( Task_Main, ( const portCHAR * const ) "Main", portMINIMAL_STACK_SIZE, ( void * ) pParamEvento1,mainTASK_MAIN, NULL );

so the task Main has to send a parameters to Task Telemetro and whit this value Task Telemetro has to send other value to Task Ruedas..... y don´t know why the program is not working... Do yuo know if i have to use a semophore or something like that to make little bit organize everything??

thanks so mucho for your help.....I was trying anything but it doesn´t work.

Thanks again for your help!!

Regards,

Adriana


RE: Problem with 3 Tasks and 2 queue

Posted by Richard on March 4, 2007
There is nothing obviously wrong in the code you have posted, but you do not show how you use the queues.

It might be that you are using a pointer incorrectly somewhere. You could declare things statically rather than dynamically. Did you copy the code from blockq.c? It seems similar. Can you get the BlockQ demo task working then adapt it for your application?

Regards.

RE: Problem with 3 Tasks and 2 queue

Posted by Nobody/Anonymous on March 4, 2007
Hello, thanks for your help... yes i do, i use the declaration in Blockq for create my tasks.... but i can´t understand wich is my error....

I´m posting the most important code of each tasks, where i´m using the queues.... there is no problem when i have two tasks and one queue the program ran ok... but now i have to add more tasks with differents queues but the program doesn´t work well...



static void Task_Main( void *pvParameters )
{

portTickType xDelayTime = mainNO_ERROR_CHECK_PERIOD;
Param_evento *pParamEvento, ParamEvento;
char mensaje_e, mensaje_enviado=1;
xMessage *pxMessage, Message;

pParamEvento = (Param_evento *) pvParameters;
ParamEvento=*pParamEvento;


Message=*pxMessage;
Message= ParamEvento->mensaje;

Message.ucMessageID=2;
Message.ucData=0;

for(;;)
{
if( cQueueSend( ParamEvento.xQueueEvento,( void * ) &Message, pParamEvento->xBlockTime ) != pdPASS )
{
mensaje_enviado=0;
}
else mensaje_enviado=1;
vTaskDelay(ParamEvento.DelayTime);
}
}




static void Task_Telemetro( void *pvParameters )
{

int fin=0;
int stop=0;
portTickType xDelayTime = mainNO_ERROR_CHECK_PERIOD;
Param_evento *pParamEvento, ParamEvento;
char mensaje_e, mensaje_enviado=1;
xMessage *pxMessage, Message;

pParamEvento = (Param_evento *) pvParameters;
ParamEvento=*pParamEvento;


Message=*pxMessage;
Message= ParamEvento->mensaje;

Message.ucMessageID=2;
Message.ucData=0;

for(;;)
{

if(fin==0)
{

if(cQueueReceive( ParamEvento.xQueueEvento, (void *)&Message, ParamEvento.xBlockTime ) == pdPASS)
{
switch(Message.ucMessageID)
{
case 1:
stop=0;
break;

case 6:
fin=1;
break;
}
}

else if(stop==0) {

if(cQueueReceive( ParamEvento.xQueueEvento, (void *)&Message, ParamEvento.xBlockTime ) == pdPASS)
{
switch(Message.ucMessageID)
{
//differents cases.................
}
}
vTaskDelay(ParamEvento.DelayTime);
}
}
}
}


static void Task_Ruedas( void *pvParameters )
{
int prueba=0;
char usDataRxEvento=0;
char dat=0;
xMessage *pxMessageRx, MessageRx;

portTickType xDelayTime = mainNO_ERROR_CHECK_PERIOD;
Param_evento *pxParamEvent, ParamEvento;

pxParamEvent= (Param_evento *) pvParameters;
ParamEvento=*pxParamEvent;
MessageRx=*pxMessageRx;
DUTY_PWM1=400;
DUTY_PWM2=400;
direccion=1;
Configuracion_PWM();



for(;;)
{

if(cQueueReceive( ParamEvento.xQueueEvento, (void *)&MessageRx, ParamEvento.xBlockTime ) == pdPASS)
{

switch( MessageRx.ucData )
{
//differents cases....

}
}


}

}

Thanks so much for your help i´m very worried about that, i´m very daleyed with my project....

Thanks again and have a nice day!...

Regards,

Adriana

RE: Problem with 3 Tasks and 2 queue

Posted by Nobody/Anonymous on March 11, 2007
Hello! Hpw are you?

I couldn´t find the error and the 3 tasks don´t work well.... CAn you help me please i´m very worried about that i don´t know what else can i do to make it works?

Would you have aby idea that can help me ??

Thanks so much for your help!

Regards,

Adriana


[ 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