Quality RTOS & Embedded Software

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


Loading

Parameter corruption with xTaskCreate

Posted by Alexandre Malo on June 17, 2009
Hi,

I want to create task and retrieve the handle, but when I call the xTaskCreate, the handle parameter get corrupted or is not passed correctly.

void vTDT_Init()
{
static unsigned char ucParamTrap;
int result;
xTaskHandle handle;

/* Start trap demo task */
result = xTaskCreate(vSendTrapTaskDemo,
(signed portCHAR*)"TRAP",
TRAP_TASK_STACK_SIZE,
&ucParamTrap,
TRAP_TASK_PRIO,
&handle
);
}

when in vTDT_Init() function, handle as a valid address. When pass to xTaskCreate, the address is change and become invalid.

Any idea why I get this behavior? This task is created in the main, so I doubt its a freeRTOS stack size problem...

Thanks

RE: Parameter corruption with xTaskCreate

Posted by Jack Peacock on June 17, 2009
The "handle" variable is allocated on the stack when you enter the vTDT_Init routine. When you exit the routine it no longer exists. Try making "handle" a global; move it out of the routine block.

RE: Parameter corruption with xTaskCreate

Posted by Alexandre Malo on June 17, 2009
Hi, I have also tried this. It's not working. There is still corruption

You say it's allocated on the stack. But wich stack? Is there a way to control that stack you are talking about? I guess it's the default micro-c stack...

Thanks

RE: Parameter corruption with xTaskCreate

Posted by Alexandre Malo on June 17, 2009
The corruption made when passing the arguments. Right in xTaskCreate the handle point to an invalid memory address.

The function stop there because there is an exception (trying to write to a protected space...)

I must put NULL atm. I can't use handles..

RE: Parameter corruption with xTaskCreate

Posted by MEdwards on June 17, 2009
Which port are you using? MCU and compiler.

RE: Parameter corruption with xTaskCreate

Posted by Alexandre Malo on June 17, 2009
Im working with CodeWarrior.

My micro-c is MCF5282. (M5282LITE)

RE: Parameter corruption with xTaskCreate

Posted by MEdwards on June 17, 2009
In which case check your compiler options. You can configure to use either register based parameter passing or stack based. Sounds like something is messed up somewhere.

RE: Parameter corruption with xTaskCreate

Posted by Alexandre Malo on June 17, 2009
You are right!! Thanks!!

My config was set to compact mode.. I guess there was a messed up in the settings.. I set it to register and its working..

I'll optimize later :)

Thanks a ton!


[ 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