xTaskNotify crashes with Visual Studio (WIN32 simulation) with FreeRTOSv10.2.1_191129

Hi,

I see FreeRTOS crashes when I included xTaskNotify() in one of the thread. I written simple code to test xTaskNotify(). This is observed with Visual Studio (WIN32 simulation) with FreeRTOSv10.2.1_191129
xSemaphoreGive() and xSemaphoreTake() works perfectly. But, it crashes when I included xTaskNotify()

Error message at Debug console: (process 26020) exited with code -1073741819.

Any suggestions?

Reference code -

void enableFlushAfterPrintf() { setvbuf(stdout, 0, _IONBF, 0); setvbuf(stdin, 0, _IONBF, 0); }
xSemaphoreHandle uartMutex01Handle = 0;
xTaskHandle defaultTaskHandle  = 0;
xTaskHandle task2Handle  = 0;
xTaskHandle task3Handle  = 0;

void Thread1(void const * argument)
{
  for( ;; )
  {
    xSemaphoreTake(uartMutex01Handle, portMAX_DELAY);
    printf("Task #1 got access\n");  
    xSemaphoreGive(uartMutex01Handle);
    vTaskDelay(1000);
  }
}

void Thread2(void const * argument)
  for( ;; )
  {
	  xTaskNotify(task3Handle, 0x01, eSetBits);
         xSemaphoreTake(uartMutex01Handle, portMAX_DELAY);
         printf("Task #2 got access\n");  
         xSemaphoreGive(uartMutex01Handle);   
    vTaskDelay(1000);
  }
}

void Thread3(void const * argument)
{
  uint32_t notifValue;
  for( ;; )
  {
         xTaskNotifyWait(pdFALSE, 0xFF, &notifValue, portMAX_DELAY);
         xSemaphoreTake(uartMutex01Handle, portMAX_DELAY);
         printf("Task #3 got access\n");  
         xSemaphoreGive(uartMutex01Handle);
         vTaskDelay(1000);
  }
}

void main_blinky(void)
{
	enableFlushAfterPrintf();

	uartMutex01Handle = xSemaphoreCreateMutex();

	defaultTaskHandle = xTaskCreate(Thread1, (signed char*) "t1", 1024, NULL, 24, NULL);  //osPriorityNormal
	task2Handle = xTaskCreate(Thread2, (signed char*) "t2", 1024, NULL, 32, NULL);  //osPriorityAboveNormal
	task3Handle = xTaskCreate(Thread3, (signed char*) "t3", 1024, NULL, 16, NULL);  //osPriorityBelowNormal

	vTaskStartScheduler();

	return 0;
}

xTaskCreate() returns either pdPASS or pdFAIL to let you know if the task was created successfully - you are assigning that to task3Handle. The task handle is passed out in the last parameter, which you have set to NULL.

See This page describes the RTOS xTaskCreate() FreeRTOS API function which is part of the RTOS task control API. FreeRTOS is a professional grade, small footprint, open source RTOS for microcontrollers. and the many examples in the download and book.

Thanks Richard for prompt response, It works now…!!
It was my error due to overlooked into (mix-up of) STM32CubeMx’s RTOS xTaskCreate()/osThreadNew()

//------ updated code -----------
BaseType_t xReturnedDefaultTask;
TaskHandle_t defaultTaskHandle = NULL;

xReturnedDefaultTask = xTaskCreate(Thread1, (signed char*) "t1", 1024, NULL, 24, &defaultTaskHandle);  //osPriorityNormal