I am Using the STM32VL_DISCOVERY board with ATOLLIC TRUE STUDIO. I was trying to using the SEMAPHORE feature of FREERTOS. But i am facing a problem that the task with highest priority gets exicuted bt other task does not.
i tried many ways bt problem is same, even i tried the tasks with same priorities, in tht the TASK1 is exicuted. Whem i saw the debugger thn i got tht it went to a infinite loop somewhere. I am a beginner with RTOS, can any one help me.
………..
static xSemaphoreHandle XSemaphore;
…………….
int main(void)
{
vSemaphoreCreateBinary( XSemaphore);
if(XSemaphore != NULL)
{
prvSetupHardware();
xTaskCreate( prvTask1, ( signed char * ) “Task1”, 100, NULL, 2, NULL );
xTaskCreate( prvTask2, ( signed char * ) “Task2”, 100, NULL, 1, NULL );
vTaskStartScheduler();
}
for( ;; );
}
static void prvTask1( void *pvParameters )
{
int i;
for(;;)
{
xSemaphoreTake( XSemaphore, portMAX_DELAY );
STM32vldiscovery_LEDOn( LED3 );
for(i=0;i<100000;i++)
{
}
xSemaphoreGive( XSemaphore);
}
}
static void prvTask2( void *pvParameters )
{
int j;
for(;;)
{
xSemaphoreTake( XSemaphore, portMAX_DELAY );
STM32vldiscovery_LEDOff( LED3);
for(j=0;j<100000;j++)
{
}
xSemaphoreGive(XSemaphore);
}
}
static void prvSetupHardware( void )
{
/* Set up the LED outputs and the button inputs. */
STM32vldiscovery_LEDInit( LED3 );
STM32vldiscovery_LEDInit( LED4 );
/* Start with the LEDs off. */
STM32vldiscovery_LEDOff( LED3 );
STM32vldiscovery_LEDOff( LED4 );
}
void vApplicationMallocFailedHook( void )
{
for( ;; );
}
void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )
{
( void ) pcTaskName;
( void ) pxTask;
for( ;; );
}
Problem with Semaphores
Problem with Semaphores
i just included the #define INCLUDE_vTaskSuspend 1
bt thr problem is same… still the task of higher priority is exicuted. bt the problem of infinite loop is not now.
bt thr problem is same… still the task of higher priority is exicuted. bt the problem of infinite loop is not now.
Problem with Semaphores
The code you have posted will execute like this:
1) The higher priority task will take the semaphore.
2) The higher priority task will run its null loop.
3) The higher priority task will give the semaphore back.
4) The higher priority task will go back to step 1 and repeat indefinitely. The lower priority task does not even run as far as blocking on the semaphore because the higher priority task never blocks.
2) The higher priority task will run its null loop.
3) The higher priority task will give the semaphore back.
4) The higher priority task will go back to step 1 and repeat indefinitely. The lower priority task does not even run as far as blocking on the semaphore because the higher priority task never blocks.
Problem with Semaphores
Thaks for ur response,
now i tried it with xSemaphoreTake( XSemaphore, portMAX_DELAY ); out of the loop,, bt it is behaviing in the same way,, now what to do,,
now i tried it with xSemaphoreTake( XSemaphore, portMAX_DELAY ); out of the loop,, bt it is behaviing in the same way,, now what to do,,
Problem with Semaphores
well, i soved the problem, nd now its working properly,,
Thanks for ur help…
Thanks for ur help…