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)
{
NVIC
SetPriority(TIMER0IRQn, 33);
LPC
TIM0->MR0 = ((((SystemCoreClock / 1000) / 40) – 1)*40); /* 2 ms? */
LPCTIM0->MCR = (3 << 0);
NVIC
EnableIRQ(TIMER0IRQn);
LPC_TIM0->TCR = (1 << 0);
xTaskCreate( MyTask1, “TaskCore”, 1200 , NULL, tskIDLE
PRIORITY+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 )
{
}
}
}