Task stops executing and disappears while other tasks continues normally

Hi I have a task that I resume from an interrupt. After some time (10 minutes too several hours) the task that gets resumed from the interrupt stop executing. This while all other tasks continues to function normally. Interrupt code: void CANRXInterrupt( void ) { ……….. xYieldRequired = xTaskResumeFromISR( canHandle ); portYIELDFROMISR( xYieldRequired ); } OS Task code: while (1) {
        CAN_ReceiveRoutine();

        vTaskSuspend( NULL );
  }
When I call vTaskList() after the task have stopped working the effected task does not appear in the list anymore. vTaskList() before CAN_T task stops executing: Name State Priority Stack Num
ShellT R 5 300 4 CANT R 1 428 3 IDLE R 0 491 6 IRT B 3 482 2 ErrorT B 6 483 5 Main_T B 2 460 1 Tmr Svc B 2 993 7 > vTaskList() after CAN_T task stops executing: Name State Priority Stack Num
ErrorT R 6 483 5 IDLE R 0 491 6 ShellT B 5 300 4 IRT B 3 477 2 MainT B 2 460 1 Tmr Svc B 2 993 7 I don’t think its stack overflow because I don’t end up in the vApplicationStackOverflowHook() and there seems to be plenty of memory still available when I call vTaskList() before the task stops working. I also don’t get caught in the configASSERT . Anyone having a clue what could be wrong here? Why does the task disappear from the vTaskList()? Info about platform: MCU: stm32f407: IDE: coocox 2.0.3. toolchain: gcc 4.8 2004. RTOS: FreeRTOS V8.2.2

Task stops executing and disappears while other tasks continues normally

If you are using the task suspend/resme mechanism to synchronise a task with an interrupt, then please don’t, it is a dangerous technique to use. Please read the documentation page of the xTaskResumeFromISR(), and other posts in this forum where people have experienced the same issue. The best and fasted way to do what you want is to use a direct to task notificiation. See http://www.freertos.org/vTaskNotifyGiveFromISR.html Regards.

Task stops executing and disappears while other tasks continues normally

Thank you for the reply! 🙂 I have tried using the vTaskNotifyGiveFromISR( canHandle, NULL ) but the program only runs for a couple of minutes before it ends up in the HardFault_Handler(). If I don’t call the portYIELDFROMISR( pdTRUE ) the program seems to work fine but the task is not started directly after the interrupt and that is not acceptable. I don’t know why I get this problem but I guess it might have something with the interrupt priority settings. But as I understand it I think the settings are correct. The interrupt priority for the interrupt calling vTaskNotifyGiveFromISR() and portYIELDFROMISR() is the following: ~~~~ NVICPriorityGroupConfig(NVICPriorityGroup4); NVICInitStructure.NVICIRQChannel = CAN1RX0IRQn; NVICInitStructure.NVICIRQChannelPreemptionPriority = 15; NVICInitStructure.NVICIRQChannelSubPriority = 15; NVICInitStructure.NVICIRQChannelCmd = ENABLE; NVICInit(&NVIC_InitStructure); ~~~~ This should be the lowest interrupt priority. The freeRTOS config settings are: ~~~~

define configLIBRARYMAXSYSCALLINTERRUPTPRIORITY 5

define configKERNELINTERRUPTPRIORITY 255

define configMAXSYSCALLINTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11.

define configLIBRARYKERNELINTERRUPT_PRIORITY 15

~~~~ Task priority is: xTaskCreate( CAN_Control_Task, ( const char * ) "CAN_T", configMINIMAL_STACK_SIZE, NULL, 1, &canHandle ); Anyone having a clue of why I end up in hard fault when I use vTaskNotifyGiveFromISR and portYIELDFROMISR from an interrupt? Or how I investigate further how to track down the fault?

Task stops executing and disappears while other tasks continues normally

Try setting the SubPriority to 0. Are you also calling NVICPriorityGroupConfig( NVICPriorityGroup_4 );? (http://www.freertos.org/RTOS-Cortex-M3-M4.html). Do you have configASSERT() defined? Do you have stack overflow checking turned on?