Hi, everyon.
i’m working on FreeRTOS, especially, implementing softtimer.
According to the manual of FreeRTOS, xTaskStartScheduler have to be activated to use soft timer, but, i can’t find this function – xTaskStartScheduler. Even thought, looking into each files of FreeRTOS. What is the problem. is there any other function which act like xTaskStartScheduler func.?… please, answer me whoever know about that… as you see web site, xTaskStartScheduler is put on the last of main(), but, my builder show me undefined reference xTaskStartScheduler…
xTaskStartScheduler
xTaskStartScheduler
vTaskStartScheduler, no xTaskStartScheduler http://www.freertos.org/a00132.html
where does it say xTaskStartScheduler?
xTaskStartScheduler
See task.h, its vTaskStartScheduler you are searching for.
xTaskStartScheduler
Example usage:
#define NUM_TIMERS 5 /* An array to hold handles to the created timers. */
xTimerHandle xTimers; /* An array to hold a count of the number of times each timer expires. */
long lExpireCounters = { 0 }; /* Define a callback function that will be used by multiple timer instances.
The callback function does nothing but count the number of times the
associated timer expires, and stop the timer once the timer has expired
10 times. */
void vTimerCallback( xTimerHandle pxTimer )
{
long lArrayIndex;
const long xMaxExpiryCountBeforeStopping = 10; /* Optionally do something if the pxTimer parameter is NULL. */
configASSERT( pxTimer ); /* Which timer expired? */
lArrayIndex = ( long ) pvTimerGetTimerID( pxTimer ); /* Increment the number of times that pxTimer has expired. */
lExpireCounters += 1; /* If the timer has expired 10 times then stop it from running. */
if( lExpireCounters == xMaxExpiryCountBeforeStopping )
{
/* Do not use a block time if calling a timer API function from a
timer callback function, as doing so could cause a deadlock! */
xTimerStop( pxTimer, 0 );
}
} void main( void )
{
long x; /* Create then start some timers. Starting the timers before the RTOS scheduler
has been started means the timers will start running immediately that
the RTOS scheduler starts. */
for( x = 0; x < NUM_TIMERS; x++ )
{
xTimers = xTimerCreate
( /* Just a text name, not used by the RTOS kernel. */
“Timer”,
/* The timer period in ticks. */
( 100 * x ),
/* The timers will auto-reload themselves when they expire. */
pdTRUE,
/* Assign each timer a unique id equal to its array index. */
( void * ) x,
/* Each timer calls the same callback when it expires. */
vTimerCallback
); if( xTimers == NULL )
{
/* The timer was not created. */
}
else
{
/* Start the timer. No block time is specified, and even if one was
it would be ignored because the RTOS scheduler has not yet been
started. */
if( xTimerStart( xTimers, 0 ) != pdPASS )
{
/* The timer could not be set into the Active state. */
}
}
} /* …
Create tasks here.
… */ /* Starting the RTOS scheduler will start the timers running as they have already
been set into the active state. */
xTaskStartScheduler(); <<———————— HERE!!!!! /* Should not reach here. */
for( ;; );
}
#define NUM_TIMERS 5 /* An array to hold handles to the created timers. */
xTimerHandle xTimers; /* An array to hold a count of the number of times each timer expires. */
long lExpireCounters = { 0 }; /* Define a callback function that will be used by multiple timer instances.
The callback function does nothing but count the number of times the
associated timer expires, and stop the timer once the timer has expired
10 times. */
void vTimerCallback( xTimerHandle pxTimer )
{
long lArrayIndex;
const long xMaxExpiryCountBeforeStopping = 10; /* Optionally do something if the pxTimer parameter is NULL. */
configASSERT( pxTimer ); /* Which timer expired? */
lArrayIndex = ( long ) pvTimerGetTimerID( pxTimer ); /* Increment the number of times that pxTimer has expired. */
lExpireCounters += 1; /* If the timer has expired 10 times then stop it from running. */
if( lExpireCounters == xMaxExpiryCountBeforeStopping )
{
/* Do not use a block time if calling a timer API function from a
timer callback function, as doing so could cause a deadlock! */
xTimerStop( pxTimer, 0 );
}
} void main( void )
{
long x; /* Create then start some timers. Starting the timers before the RTOS scheduler
has been started means the timers will start running immediately that
the RTOS scheduler starts. */
for( x = 0; x < NUM_TIMERS; x++ )
{
xTimers = xTimerCreate
( /* Just a text name, not used by the RTOS kernel. */
“Timer”,
/* The timer period in ticks. */
( 100 * x ),
/* The timers will auto-reload themselves when they expire. */
pdTRUE,
/* Assign each timer a unique id equal to its array index. */
( void * ) x,
/* Each timer calls the same callback when it expires. */
vTimerCallback
); if( xTimers == NULL )
{
/* The timer was not created. */
}
else
{
/* Start the timer. No block time is specified, and even if one was
it would be ignored because the RTOS scheduler has not yet been
started. */
if( xTimerStart( xTimers, 0 ) != pdPASS )
{
/* The timer could not be set into the Active state. */
}
}
} /* …
Create tasks here.
… */ /* Starting the RTOS scheduler will start the timers running as they have already
been set into the active state. */
xTaskStartScheduler(); <<———————— HERE!!!!! /* Should not reach here. */
for( ;; );
}
xTaskStartScheduler
xTaskStartScheduler
Typo – now fixed. Thanks.
Regards.