Hi all,
I am a new user of FreeRTOS and currently I am facing a problem related to semaphore. I tried to do some research but I cannot seem to find a similar case like mine.
I am using STM32f407 with STM32 standard peripheral drivers and Keil as development environment. I set an interrupt which can be detected well by my interrupt handler. My code works fine at first, but after some random duration time has passed, suddenly my ISR routine doesn’t work anymore. Interrupt is still detected by ISR handler and semaphore is given using xSemaphoreGiveFromISR(), but the interrupt routine cannot be executed because (I think) it cannot take semaphore.
void ISR_handler(){
if(INTERRUPT_FLAG){
// code to clear interrupt pending bit here
/* Frame received */
/* Give the semaphore to LwIP task (ISR routine) */
xSemaphoreGiveFromISR(s_xSemaphore, &xHigherPriorityTaskWoken);
}
}
void ISR_routine( void * pvParameters ){
struct pbuf *p;
for( ;; ){
if (xSemaphoreTake( s
xSemaphore, 100tick)==pdTRUE){
/* Interrupt Routine start */
p = low_level_input( s_pxNetIf );
if (p != NULL){
if (ERR_OK != s_pxNetIf->input( p, s_pxNetIf)){
pbuf_free(p);
p=NULL;
}
}
/* Interrupt Routine end */
} //if
} //for
}
The semaphore that I use is counting semaphore. After the error occur, I have checked that ISR
handler is still generated and xSemaphoreGivefromISR is still executed. However, the infinite loop on ISRroutine is not executed. I have checked the stack size of my ISR routine task and stack overflow is far from happening.
I have debugged this problem for a couple of days now, but I cannot seem to come to a conclusion. Please advise or give me suggestion to find out the general reason that a semaphore cannot be taken by xSemaphoreTake.
Thanks!