Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists