xTaskCreate Parameter Error

groufosse wrote on Wednesday, March 27, 2013:

I’m getting this error when I compile :
Error: argument of type “void (*)(void *, void *)” is incompatible with parameter of type “pdTASK_CODE” C:\Users\jdd\Documents\IAR Embedded Workbench\Code_Base\RTOS\System_Control.c 36

Can someone please tell me what might cause this? It’s in a separate file (System_Control.c) , in a function that’s called from main(), which that function is declared in a header file. Here is the call from main:
ReadCOMmBufferTaskFunction( pvParameters );

The function in main is itself a task created by “xTaskCreate”

Thanks for any help!

richard_damon wrote on Wednesday, March 27, 2013:

The error say that the task function being passed at this point is taking two parameters, both of which are pointer to void. This is the wrong signature. A task function needs to have exactly 1 parameter, of type pointer to void.

Check carefully the function, and its signature, on the line being flaged as an error.

groufosse wrote on Wednesday, March 27, 2013:

Thanks - that fixed it. Sometimes those messages can be a bit cryptic to the non-experienced.
What I was trying to do was pass in an additional parameter - the xMutexMemoryAccess handle. I was not aware I couldn’t add extra parameters to the function call. I need to get that handle over to the C file that has functions that use it. it’s also used in the C file where it’s created. No other way to get it over other than using an “extern” ?

rtel wrote on Wednesday, March 27, 2013:

The void * parameter allows you to send whatever you want - but it has to be a single parameter.  If you want to send multiple parameters then place the parameters in a structure and send a pointer to the structure.  Here is an example from one of the standard demo tasks:

/* Structure used to pass parameters to each task. */
  xSemaphoreHandle xSemaphore;
  volatile unsigned long *pulSharedVariable;
  portTickType xBlockTime;
} xSemaphoreParameters;
/* Create the structure used to pass parameters to the first two tasks. */
pxFirstSemaphoreParameters = pvPortMalloc( sizeof( xSemaphoreParameters ) );
if( pxFirstSemaphoreParameters != NULL )
  /* Create the semaphore used by the first two tasks. */
  vSemaphoreCreateBinary( pxFirstSemaphoreParameters->xSemaphore );
  if( pxFirstSemaphoreParameters->xSemaphore != NULL )
    /* Create the variable which is to be shared by the first two tasks. */
    pxFirstSemaphoreParameters->pulSharedVariable = 
                ( unsigned long * ) pvPortMalloc( sizeof( unsigned long ) );
    /* Initialise the share variable to the value the tasks expect. */
    *( pxFirstSemaphoreParameters->pulSharedVariable ) = 
    /* The first two tasks do not block on semaphore calls. */
    pxFirstSemaphoreParameters->xBlockTime = ( portTickType ) 0;
    /* Spawn the first two tasks.  As they poll they operate at the idle 
    priority. */
    xTaskCreate( prvSemaphoreTest, 
                 ( signed char * ) "PolSEM1", 
           semtstSTACK_SIZE, ( void * ) 
           ( xTaskHandle * ) NULL );


groufosse wrote on Wednesday, March 27, 2013:


Thanks for taking the time to explain this. I’ll give that a try as it looks to be what I need.