Resuming task from interrupt delay problem

inimicus8 wrote on Monday, September 21, 2015:

Hi I have a problem that it takes a long time to resume a task when i call ”xTaskResumeFromISR” from within a interrupt. It takes at least 7ms from that I call ”xTaskResumeFromISR” to that the task starts executing. The delay time slowly increases to over 100ms.
If i call vTaskResume from another task the task resumes immediately. I only have one interrupt on and only one other task that only contains a while loop and vTaskDelay(100/portTICK_RATE_MS);. (if I don’t have another task I can’t run the program for some reason)

program:

main:
{
xTaskCreate( taskB, ( signed char * ) “taskB”, configMINIMAL_STACK_SIZE, NULL, 2, NULL );

xTaskCreate( CAN_Control_Task, ( signed char * ) “C_Control”, configMINIMAL_STACK_SIZE, NULL, 1, &canHandle );

// FreeRTOS start
vTaskStartScheduler();

}

void CAN_Control_Task( void* pdata )
{
CAN_Config();
while (1)
{
CAN_ReceiveRoutine();
vTaskSuspend( NULL );
// ulTaskNotifyTake( pdTRUE, (10000/portTICK_RATE_MS) );
}
}

void CAN_RX_Interrupt( void )
{
BaseType_t xHigherPriorityTaskWoken = pdTRUE;

IO_OkStatusLedOn();
if (CAN_GetITStatus(CANx, CAN_IT_FMP0) != RESET)
{
    .......................................
  
	xTaskResumeFromISR( canHandle );
	//  vTaskNotifyGiveFromISR( canHandle , &xHigherPriorityTaskWoken );
	 CAN_ClearITPendingBit(CANx, CAN_IT_FMP0);
}

}

Does anyone know why this happens and how to fix it?
Same thing happens when I use “ulTaskNotifyTake” and “vTaskNotifyGiveFromISR”
When I run my program In CoOS I don’t get this problem.

Info about platform: MCU: stm32f407: IDE: coocox 2.0.3. toolchain: gcc 4.8 2004. RTOS: FreeRTOS V8.2.2

rtel wrote on Monday, September 21, 2015:

Please read the documentation for the xTaskResumeFromISR() as it tells you two things:

  1. Don’t use the function to synchornise a task with an interrupt - it is dangerous and can lead to missed interrupts as it does not latch interrupts (like a semphore or task notification would). That might be what your problem is.

  2. Use the function’s return value to know if a context switch is required:

xYieldRequired = xTaskResumeFromISR( handle );
portYIELD_FROM_ISR( xYieldRequired );

inimicus8 wrote on Monday, September 21, 2015:

Yep that fixed it!!

I had totally missed that the “portYIELD_FROM_ISR” function existed.
Thank you very much for a fast reply
:slight_smile:

alainm3 wrote on Monday, September 21, 2015:

Buy the book, it will save you days of fiddling around !!!

Alain

Em 21-09-2015 09:50, Jimmie Hansson escreveu:

Yep that fixed it!!

I had totally missed that the “portYIELD_FROM_ISR” function existed.
Thank you very much for a fast reply
:slight_smile:


Resuming task from interrupt delay problem
https://sourceforge.net/p/freertos/discussion/382005/thread/842d6424/?limit=250#941c


Sent from sourceforge.net because you indicated interest in
SourceForge.net: Log In to SourceForge.net

To unsubscribe from further messages, please visit
SourceForge.net: Log In to SourceForge.net