Task stops executing and disappears while other tasks continues normally

inimicus8 wrote on Monday, October 12, 2015:

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 CAN_RX_Interrupt( void )
xYieldRequired = xTaskResumeFromISR( canHandle );
portYIELD_FROM_ISR( xYieldRequired );

OS Task code:
while (1)


		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

Shell_T R 5 300 4
CAN_T R 1 428 3
IDLE R 0 491 6
IR_T B 3 482 2
Error_T 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

Error_T R 6 483 5
IDLE R 0 491 6
Shell_T B 5 300 4
IR_T B 3 477 2
Main_T 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

rtel wrote on Monday, October 12, 2015:

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


inimicus8 wrote on Monday, October 12, 2015:

Thank you for the reply! :slight_smile:
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 portYIELD_FROM_ISR( 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 portYIELD_FROM_ISR() is the following:

  NVIC_InitStructure.NVIC_IRQChannel = CAN1_RX0_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 15;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 15;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

This should be the lowest interrupt priority.

The freeRTOS config settings are:

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

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 portYIELD_FROM_ISR from an interrupt? Or how I investigate further how to track down the fault?

rtel wrote on Monday, October 12, 2015:

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