FreeRTOS stuck when using vTaskDelay function

Hello guys,
I am having a problem with my application.
MCU is a STM32L071CBT6 and currently it gets stuck when I use the vTaskDelay function.
The application is simple: 2 tasks
The first task initialize peripherals and then delete itself.
The second task is just a blinking led which blinks only once and then stops when vTaskDelay(delay) is executed for the first time.
I have tried to debug and found the application gets stuck in the while loop of this function in the task.c file:
static void prvCheckTasksWaitingTermination( void )

Do you have any idea of what the problem might be?

Hi @migmel,
I think prvCheckTasksWaitingTermination is called by idle task, which means your task is getting suspended or deleted. It should be back after timeout if it’s just delayed.
Could you share your code on second task?

Otherwise, did you define configASSERT in your project? That helps if you actually hit an exception.

Thanks.

Thank you for you reply,
Here is the most relevant of the tasks I’m using:

void freertos_init(void) {
  /* Create tasks, ... */
	xTaskCreate(Welcome, "Welcome", 128\*2, NULL, 2, NULL);
  xTaskCreate(status, "STATUS", 128, NULL, 1, &hstatus);
}

First task, delete itself:

void Welcome(void *pvParameters){
	for(;;){
		/* Initialization */
		device_Init();
		printf("*** FreeRTOSv202112.00 (March 25,2023) *** \r\n\r\n");
		vTaskDelete(NULL);
	}
}

second task using vTaskDelay:

void status(void *pvParameters){
	for(;;){
		printf("\r\nLED STATUS");
		LL_GPIO_TogglePin(StatusLED_Port, StatusLED_Pin);
		vTaskDelay( 500 / portTICK_RATE_MS );
//		for(volatile int i=0; i<2500000; i++);
	}	
}

The commented line is just an artificial delay to test that it works when no using vTaskDelay.
This is how configASSERT is set in FreeRTOSConfig.h:

#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }

Might it be a problem with the clock configuration ?

You should also enable stack checking .
Probably the stack size of status task is too small b/c you’re using stack hungry printf (family) function.
You should also check the return code of xTaskCreate to see if it was successful.

In addition to @hs2 recommendation, could you help to set a breakpoint at xTaskIncrementTick to check if system tick runs?

Thanks.

Hello guys,
Thank you for your help.
I started over from the ground and the problem disappeared.
I guess some configuration was wrong and it seemed easier to start over because debugging FreeRTOS is kind of hard to me.
Thank you all

Thank you for reporting back.