Thread does not run

I have created three threads. One of them has the higher priority than two others and I use a binary semaphore to synchronize it with an ISR. ISR releases semaphore and wakes up the highest priority thread. Other two threads run while the highest priority thread is blocked for acquiring semaphore. The problem is after a while the higher priority thread does not run at all. I use LED blinking test and found every time it does not run, the semaphore has been released by the ISR, but the thread does not stuck in acquiring semaphore. It does not run completely. Other two threads run normally while the highest one does not. I use the empty body loops for all three threads but the problem persists. I use cortexM3(LPC1788) and freeRTOS ver 6.1.0 Your help would be greatly appreciated, Elham void TIMER0_IRQHandler(void) //2 ms interrupt { xHigherPriorityTaskWoken = pdFALSE; xSemaphoreGiveFromISR(hADCSemaphore, &xHigherPriorityTaskWoken); } int main(void) { NVICSetPriority(TIMER0IRQn, 33); LPCTIM0->MR0 = ((((SystemCoreClock / 1000) / 40) – 1)*40); /* 2 ms? */ LPCTIM0->MCR = (3 << 0); NVICEnableIRQ(TIMER0IRQn); LPC_TIM0->TCR = (1 << 0); xTaskCreate( MyTask1, “TaskCore”, 1200 , NULL, tskIDLEPRIORITY+1 , NULL ); xTaskCreate( MyTask2 , “TaskGraphics”, 1500, NULL, tskIDLEPRIORITY+1, NULL ); xTaskCreate( MyTask3, “TaskTouchScreen”, 3000, NULL, tskIDLE_PRIORITY+2, NULL ); vSemaphoreCreateBinary(hADCSemaphore); vTaskStartScheduler(); while(1); } static void MyTask1(void* pvParameters) { while(1) {
    }
} static void MyTask2(void* pvParameters) { while(1) { } } static void MyTask3(void* pvParameters) { while(1) { if( xSemaphoreTake( hADCSemaphore, portMAX_DELAY ) == pdTRUE ) {
      }
    }
}

Thread does not run

I don’t fully understand the description of the problem.
The problem is after a while the higher priority thread does not run at all. I use LED blinking test and found every time it does not run,
I’m not sure if you are saying it never runs (“ever time it does not run”) or that it starts of ok, but after a while it stops running (“after a while the higher priority thread does not run”).
I use cortexM3(LPC1788) and freeRTOS ver 6.1.0
Yikes – that is very, very old.
void TIMER0_IRQHandler(void) //2 ms interrupt { xHigherPriorityTaskWoken = pdFALSE; xSemaphoreGiveFromISR(hADCSemaphore, &xHigherPriorityTaskWoken); }
If you want the high priority task to run immediately the semaphore is given then you need to call portYIELDFROMIS( xHigherPriorityTaskWoken ) – or possibley portENDSWITCHINGISR( xHigherPriorityTaskWoken ) – at the end of the ISR – I can’t remember for that version but look at the examples that come with that version to determine which.
int main(void) { NVICSetPriority(TIMER0IRQn, 33);
Make sure you read https://www.freertos.org/RTOS-Cortex-M3-M4.html as setting the priorities is complex on a Cortex-M. If you were using FreeRTOS V10 then you could defined configASSERT() and that would tell you if you had any of the configuration wrong – it will be much harder in V6.
static void MyTask3(void* pvParameters) { while(1) { if( xSemaphoreTake( hADCSemaphore, portMAX_DELAY ) == pdTRUE ) {
   }
 }
}
Looks ok.