# xTaskCreate Parameter Error

**URL:** <https://forums.freertos.org/t/xtaskcreate-parameter-error/826>\
**Category:** Kernel\
**Created:** [March 27, 2013, 1:21am UTC](https://forums.freertos.org/t/xtaskcreate-parameter-error/826 "2013-03-27T01:21:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 27, 2013, 1:21am UTC](https://forums.freertos.org/t/xtaskcreate-parameter-error/826/1 "2013-03-27T01:21:08Z")

</div>

**[groufosse](https://sourceforge.net/u/groufosse/)** wrote on [Wednesday, March 27, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/255bc0ed/#2fb2):

Hi,  
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!

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [March 27, 2013, 3:40am UTC](https://forums.freertos.org/t/xtaskcreate-parameter-error/826/2 "2013-03-27T03:40:59Z")

</div>

**[richard\_damon](https://sourceforge.net/u/richard_damon/)** wrote on [Wednesday, March 27, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/255bc0ed/#8765):

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.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 27, 2013, 3:16pm UTC](https://forums.freertos.org/t/xtaskcreate-parameter-error/826/3 "2013-03-27T15:16:35Z")

</div>

**[groufosse](https://sourceforge.net/u/groufosse/)** wrote on [Wednesday, March 27, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/255bc0ed/#3516):

Hi,  
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” ?

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [March 27, 2013, 3:32pm UTC](https://forums.freertos.org/t/xtaskcreate-parameter-error/826/4 "2013-03-27T15:32:30Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Wednesday, March 27, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/255bc0ed/#b231):

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

```
/* Structure used to pass parameters to each task. */
typedef struct SEMAPHORE_PARAMETERS
{
  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 ) = 
                semtstNON_BLOCKING_EXPECTED_VALUE;
    /* 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 * ) 
           pxFirstSemaphoreParameters, 
           tskIDLE_PRIORITY, 
           ( xTaskHandle * ) NULL );
  }
}

```

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 27, 2013, 5:54pm UTC](https://forums.freertos.org/t/xtaskcreate-parameter-error/826/5 "2013-03-27T17:54:04Z")

</div>

**[groufosse](https://sourceforge.net/u/groufosse/)** wrote on [Wednesday, March 27, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/255bc0ed/#e978):

Richard,

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