This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMDSIDK574: How to make multiple Task with Task_Create() in code

Part Number: TMDSIDK574


Hi Expert,

I'm developing my code on idkAM574x EVM.

I have several tasks to be run concurrently.

So, I tried to create two tasks with Task_create() API as below.

Int main()
{ 
    Task_Handle task;
    Task_Handle ledtask;
    Task_Params maintaskParams, ledtaskParams;
    Error_Block eb_main, eb_led;



    Board_initialize();

    Error_init(&eb_main);
    Error_init(&eb_led);

    UART_printf("enter main()\n");

    /* LedToggleTask */
    Task_Params_init(&ledtaskParams);
    ledtaskParams.priority = 2;
    ledtaskParams.instance->name = "ledToggleTask";

    ledtask = Task_create(LedToggleTask, &ledtaskParams, &eb_led);
    if (ledtask == NULL) {
        UART_printf("LedToggleTask Task_create() failed!\n");
        BIOS_exit(0);
    }
    /* mainTask */
    Task_Params_init(&maintaskParams);
    maintaskParams.priority = 1;
    maintaskParams.instance->name = "mainTask";

    task = Task_create(taskFxn, &maintaskParams, &eb_main);
    if (task == NULL) {
        UART_printf("taskFxn Task_create() failed!\n");
        BIOS_exit(0);
    }


    BIOS_start();    /* does not return */
    return(0);
}

But the second task always failed and Task_create() returned NULL.

Code block for each task works well.

And when I configure multiple task in .cfg as below, all task works well without any failure.

var task1Params = new Task.Params();
task1Params.instance.name = "task1";
task1Params.stackSize = 0x1000;
Program.global.task1 = Task.create("&taskFxn", task1Params);

var task2Params = new Task.Params();
task2Params.instance.name = "task2";
task2Params.stackSize = 0x1000;
Program.global.task2 = Task.create("&LedToggleTask", task2Params);

Even more than two tasks work well.

What is my fault?

Can anybody help me with solving this issue?

Thank you.

Best regards,

James.