FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [May 2011 Threads] Use API in interruptPosted by yaozhiman on May 9, 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? regards
RE: Use API in interruptPosted by woops_ on May 9, 2011 http://www.freertos.org/a00110.html#kernel_priority
Only api that have FromISR in the name can every be called in in interrupt. The link above describes the other things.
RE: Use API in interruptPosted by yaozhiman on 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 */ NVIC_SetPriority(DMA1_Channel1_IRQn,11); NVIC_EnableIRQ(DMA1_Channel1_IRQn);//
#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; if(((DMA1->ISR)&0x02)) { TIM4->CR1&=(~0x01); xSemaphoreGiveFromISR( xSemaphoreHandle1, &xHigherPriorityTaskWoken ); DMA1->IFCR=0x02; // printf("DMA1_Channel1_IRQHandler is Running!\n");//ITM trace } if( xHigherPriorityTaskWoken ) { vPortYieldFromISR(); } //xTaskGetTickCount(); //TIM4->CR1|=0x01; }
void vTaskAdc1( void * pvParameters ) { ADC1_Parameter_Init(); //TIM4->CR1|=0x01; while(1) { if( xSemaphoreTake( xSemaphoreHandle1, portMAX_DELAY) == pdTRUE ) { ADC_Handle2(); TIM4->CR1|=0x01; //printf("vTaskAdc1 is Running!\n"); } } } I tested for a few days it still run very well.
Regards
RE: Use API in interruptPosted by Richard on 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.
Regards.
RE: Use API in interruptPosted by yaozhiman on 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 regards
RE: Use API in interruptPosted by Richard Damon on 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).
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|