Use API in interrupt

yaozhiman wrote on Monday, May 09, 2011:

I am very confused about use API in interrupt ,In this sentence-"API functions must not be called from an interrupt if the interrupt has a priority above the priority set by configMAX_SYSCALL_INTERRUPT_PRIORITY."Do all of the API cannot be called or part  API cannot be called?If I  use the API in a higher priority interrupt, does the system will collapse crash?

woops_ wrote on Monday, May 09, 2011:

Only api that have FromISR in the name can every be called in in interrupt. The link above describes the other things.

yaozhiman wrote on Tuesday, May 10, 2011:

it is this, I build a DMA interrupt and a task in my project, the interrupt priority of DMA  is higher than configMAX_SYSCALL_INTERRUPT_PRIORITY 's priority ,which can preempted the OS’s interruption. the interrupt of DMA send a semaphore to the task by xSemaphoreGiveFromISR( xSemaphoreHandle1, &xHigherPriorityTaskWoken );and the task receive semaphore by call xSemaphoreTake (xSemaphoreHandle1, if (portMAX_DELAY) = = pdTRUE) , according to the conventional ,ths OS should Crash, but I tested for a few days it still run very well.

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);//set DMA’s priority =11
  /* Enable the DMA1 Interrupt */

#define configKERNEL_INTERRUPT_PRIORITY (15<<4)
#define configMAX_SYSCALL_INTERRUPT_PRIORITY (13<<4) /* . */

void DMA1_Channel1_IRQHandler(void)//ADC is triggered by Timer4’s PWM
   signed portBASE_TYPE xHigherPriorityTaskWoken= pdFALSE;
      xSemaphoreGiveFromISR( xSemaphoreHandle1, &xHigherPriorityTaskWoken );
     // printf(“DMA1_Channel1_IRQHandler is Running!\n”);//ITM trace
    if( xHigherPriorityTaskWoken  )

void vTaskAdc1( void * pvParameters )
       if( xSemaphoreTake( xSemaphoreHandle1, portMAX_DELAY) == pdTRUE )
          //printf(“vTaskAdc1 is Running!\n”);
I tested for a few days it still run very well.


rtel wrote on Tuesday, May 10, 2011:

If you are relying on your system not crashing, then don’t do it, and stick to the rules.  You may get luck for days, weeks, years even, but there is a bug in your code that is just waiting for all the necessary circumstances to happen, by change, simultaneously.

Lower the interrupt priority so it is equal to or less than configMAX_SYSCALL_INTERRUPT_PRIORITY.

Are you sure what you think is a higher priority really is?  If this is a cortex M3 system, then high numeric values equate to *low* actual priority values.


yaozhiman wrote on Thursday, May 12, 2011:

I think it’s so, assuming that,the  priority of  DMA1_Channel1_IRQHandler is above configMAX_SYSCALL_INTERRUPT_PRIORITY, and suppose that only a DMA1_Channel1_IRQHandler calls xSemaphoreGiveFromISR (xSemaphoreHandle1, & xHigherPriorityTaskWoken), so long as DMA1_Channel1_IRQHandler does not preempte itself, the system is safe, is  right? Also ,is the different  of the priority of DMA1_Channel1_IRQHandler  is above or below configMAX_SYSCALL_INTERRUPT_PRIORITY that when  DMA1_Channel1_IRQHandler call API,the DMA1_Channel1_IRQHandler may be nested by itself or be nested by other interrupt, which could cause the abnormal of API’s execute , is this?(the CPU is STM32)
       Above is my stupid idea and my English isn’t good

richard_damon wrote on Saturday, May 14, 2011:

If an interrupt has a priority such that a critical section does not disable the interrupt, (based on configMAX_SYSCALL_INTERRUPT_PRIORIRY) then the program runs the risk of corruption if the interrupt occurs during a critical section in a task level operation. It doesn’t matter if no one else is calling a given FromISR function, the danger is in manipulating the common base data structures (ready lists and the like).