Parameter corruption with xTaskCreate

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

Parameter corruption with xTaskCreate

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.

Parameter corruption with xTaskCreate

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

Parameter corruption with xTaskCreate

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..

Parameter corruption with xTaskCreate

Which port are you using?  MCU and compiler.

Parameter corruption with xTaskCreate

Im working with CodeWarrior. My micro-c is MCF5282. (M5282LITE)

Parameter corruption with xTaskCreate

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.

Parameter corruption with xTaskCreate

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!