Can't create a second xTaskCreatePinnedToCore()

mattismyo
Posts: 29
Joined: Sat Jun 10, 2017 6:56 am

Can't create a second xTaskCreatePinnedToCore()

Postby mattismyo » Mon Aug 07, 2017 11:29 am

I try to create a Task which is pinned to Core 0, but it fails. My other task works fine.
Here is a code snippet:

Code: Select all

void task1(void* arg)
{
    //This works
}

void task2(const char* data)
{
    //This not
}

    xTaskCreatePinnedToCore(
        task1, /* Function to implement the task */
        "task1", /* Name of the task */
        8192, /* Stack size in words */
        NULL, /* Task input parameter */
        1, /* Priority of the task */
        NULL, /* Task handle. */
        1); /* Core where the task should run */

      xTaskCreatePinnedToCore(
        task2, /* Function to implement the task */
        "task2", /* Name of the task */
        8192, /* Stack size in words */
        NULL, /* Task input parameter */
        2, /* Priority of the task */
        NULL, /* Task handle. */
        0); /* Core where the task should run */
error: invalid conversion from 'void (*)(const char*)' to 'TaskFunction_t {aka void (*)(void*)}' [-fpermissive]
0); /* Core where the task should run */
Is it because of 'const char* data' in my function task2?

krajaan
Posts: 16
Joined: Mon Mar 20, 2017 5:59 pm

Re: Can't create a second xTaskCreatePinnedToCore()

Postby krajaan » Mon Aug 07, 2017 11:52 am

Hi,
FreeRTOS uses

Code: Select all

void task(void* param)
as the function's signature. Any other function signature breaks ABI.
To work around this, pass the pointer to your data as a void pointer and cast and assign it to the preferred type of variable on function entry, like so:

Code: Select all

const char* data = (const char*) param;

mattismyo
Posts: 29
Joined: Sat Jun 10, 2017 6:56 am

Re: Can't create a second xTaskCreatePinnedToCore()

Postby mattismyo » Mon Aug 07, 2017 12:14 pm

Thanks!

Who is online

Users browsing this forum: Bing [Bot] and 333 guests