princechauhan wrote on Tuesday, November 20, 2012:
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( ;; );
}