vTaskDelay() doesn't work

Hello,

I am new user of Free RTOS and have a question regarding vTaskDelay(). I checked the forum regarding my problem, but didn’t find anything that would help me.
I am using the Free RTOS on AurixTC33 microcontroller. First I implemented two tasks, where first task toggle one diode and secound task toggle another diode. Then I used the while loop for blocking delay function, so everything worked properly when it is designed like this.
However, when I put vTaskDelay() function to have nonbloking delay instead of blocking delay function the diodes do not toggle properly.
When I’m debugging this code, I go into the vTaskDelay function but it seems that it doesn’t blocked the desired task and that it doesn’t do any context switch. So, it only toggle LED diode from one of two tasks with frequency same as System timer that is using for calling scheduler.
Has anyone encountered the similar problem and does anyone have any idea what the problem is?
In FreeRTOSConfig.h file the macro INCLUDE_vTaskDelay is defined as 1.
For me, who is begginer in this field it seems that vTaskDelay function affects in that way so that the scheduler stops working and there is no any kind of delay.
Below is part of the code.

Part from main function where the tasks are created.

status = xTaskCreate(task1_handler,"Task-1",200,NULL,5,NULL);
configASSERT(status == pdPASS);
status = xTaskCreate(task2_handler,"Task-2",200,NULL,5,NULL);
configASSERT(status == pdPASS); 
vTaskStartScheduler();

Task1_handler and task2_handler functions are below.

static void task1_handler(void *parameters)
{

    while(1)
    {

        IfxPort_togglePin(LED1);
        vTaskDelay(pdMS_TO_TICKS(1000));

    }

}
static void task2_handler(void *parameters)
{
    while(1)
    {
        vTaskDelay(pdMS_TO_TICKS(1000));
        IfxPort_togglePin(LED2);

    }

}

Thank you

What does this mean ? Setting delay ticks to 0 ?
This would change your tasks into busy loops toggling the LEDs with max. possible speed and a context switch between those tasks with equal prio only happens after a time slice (scheduler tick period) if configUSE_TIME_SLICING is enabled.
See also FreeRTOS - The Free RTOS configuration constants and configuration options - FREE Open Source RTOS for small real time embedded systems > configUSE_TIME_SLICING

Thank you for your reply.

However, when I put vTaskDelay() function to have nonbloking delay instead of blocking delay function the diodes do not toggle properly.

What does this mean ? Setting delay ticks to 0 ?

This means that when I put vTaskDelay() function in my code with the number of ticks equivalent to 1 second, the program doesn’t work properly.

vTaskDelay(pdMS_TO_TICKS(1000));

It works as follows: one LED blink at maximum speed and another LED doesn’t toggle at all. The program behaves like there is not any kind of delay (it toggle diode with max possible speed), plus it toggles only one diode, there is not any kind of context switch.
I checked configUSE_TIME_SLICING macro in my code and it is enabled.

Have you any other idea what could be issue?

Hmm … sounds like the SysTick is not running. Hence no time slicing, too.
Can you verify that xTaskIncrementTick is invoked (by putting a breakpoint at it) resp. if xTickCount is incrementing ?
But I’m not familiar with Aurix controllers. Where did you get the FreeRTOS port for from ?

This is not how the the vTaskDelay is implemented. Is is simply a software timer that puts the task in a blocked state, counts the ticks and unblock the task once it expires.

One thing you can try to create a periodic task is to use vTaskDelayUntil instead. It works like this:

#define POLLING_RATE      ( 1000 / portTICK_PERIOD_MS )    //1000ms

static portTASK_FUNCTION( prvMyTask, pvParameters )
{
    (void)pvParameters;
    TickType_t xLastWakeTime;

    xLastWakeTime = xTaskGetTickCount();
    while (true)
    {
        //This task should really do some stuff
        
        vTaskDelayUntil( &xLastWakeTime, POLLING_RATE );
    } //while (true))
}

Please share your FreeRTOSConfig.h. Also try to increase the stack size of tasks just to test.