Quality RTOS & Embedded Software

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


Loading

xTaskCreate Parameter Error

Posted by rog57 on March 27, 2013
Hi,
I'm getting this error when I compile :
Error[Pe167]: 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!


RE: xTaskCreate Parameter Error

Posted by Richard Damon on 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.

RE: xTaskCreate Parameter Error

Posted by rog57 on March 27, 2013
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" ?


RE: xTaskCreate Parameter Error

Posted by Richard on 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. */
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.

RE: xTaskCreate Parameter Error

Posted by rog57 on March 27, 2013
Richard,

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



[ 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