This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

One 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.

Your help would be greatly appreciated,
Elham


void TIMER0_IRQHandler(void)  //2 ms interrupt
{
        xHigherPriorityTaskWoken = pdFALSE;
        xSemaphoreGiveFromISR(hADCSemaphore, &xHigherPriorityTaskWoken);
}

int main(void)
{

NVIC_SetPriority(TIMER0_IRQn, 33);
LPC_TIM0->MR0 = ((((SystemCoreClock / 1000) / 40) - 1)*40);     /* 2 ms? */
LPC_TIM0->MCR = (3 << 0);
NVIC_EnableIRQ(TIMER0_IRQn);
LPC_TIM0->TCR = (1 << 0);

xTaskCreate( MyTask1, "TaskCore", 1200 , NULL, tskIDLE_PRIORITY+1 , NULL );
xTaskCreate( MyTask2 , "TaskGraphics", 1500, NULL, tskIDLE_PRIORITY+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 )
          {

          }
        }
}