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, ¬ifValue, 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;
}