Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

xTaskStartScheduler

Posted by park kwan woo on April 15, 2013
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...

RE: xTaskStartScheduler

Posted by woops_ on April 15, 2013
vTaskStartScheduler, no xTaskStartScheduler http://www.freertos.org/a00132.html

where does it say xTaskStartScheduler?

RE: xTaskStartScheduler

Posted by Friedrich Lobenstock on April 15, 2013
See task.h, its vTaskStartScheduler you are searching for.

RE: xTaskStartScheduler

Posted by park kwan woo on April 15, 2013
Example usage:
#define NUM_TIMERS 5

/* An array to hold handles to the created timers. */
xTimerHandle xTimers[ NUM_TIMERS ];

/* An array to hold a count of the number of times each timer expires. */
long lExpireCounters[ NUM_TIMERS ] = { 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[ lArrayIndex ] += 1;

/* If the timer has expired 10 times then stop it from running. */
if( lExpireCounters[ lArrayIndex ] == 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[ x ] = 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[ x ] == 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[ x ], 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( ;; );
}


RE: xTaskStartScheduler

Posted by park kwan woo on April 15, 2013
http://www.freertos.org/FreeRTOS-timers-xTimerCreate.html <--- Refer here

RE: xTaskStartScheduler

Posted by Richard on April 15, 2013
Typo - now fixed. Thanks.

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS