how much efficient software timer is
Hi,
I need three software timer for my application.
I was thinking to use software timer. but i have doubt regarding this.
How much efficient software timers are as compare to hardware?
if i use it for 100 ms then, how much error can be?
how much efficient software timer is
All software timers use the same task, so RAM is used for the task stack, but after that there is little extra RAM used for 3 tasks than 1. If the period is 100ms then use a software timer and the resolution will be one tick period if the timer task has the highest priority http://www.freertos.org/Configuring-a-real-time-RTOS-application-to-use-software-timers.html. If the period was a lot less, 500us say then use an interrupt.
how much efficient software timer is
Ok thanks.
means software timer and hardware both are same, correct?
But for small period i have to use hardware and rest i can use software timer.
is there any limitation for software timer?
how much efficient software timer is
means software timer and hardware both are same, correct?I don’t understand that sentence. Software timers are under the control of the FreeRTOS scheduler. How they are scheduled depends on the FreeRTOSConfig.h settings (link already provided). Their time resolution is basically the same as that for tasks – which is whatever configTICKRATEHZ is set to. If the resolution is adequate for your application, then you can use a software timer. The resolution of hardware timers is dependent on the clocks available on whatever hardware you are running your application on.
how much efficient software timer is
means software timer and hardware both are same, correct?Here i meant to say, is software timer are same as hardware timer? Means as Hardware timer overflows and gave interrrupt. Again, i want to know specifically about latancy. what is time latancy after overflow and timeout function being called? Actually, i have some such task.
how much efficient software timer is
Again, i want to know specifically about latency.Richard already answered this question: ~~~~~ Their time resolution is basically the same as that for tasks – which is whatever configTICKRATEHZ is set to ~~~~~ There are many ways to implement “a timer”. Here are some examples:
- Using
timers.c
: this is convenient if you want a function to be called at a certain moment or regularly at fixed intervals. If the tick-rate is 1000 Hz, then the expected latency is at most a ms, unless your CPU is busy running higher-priority tasks. Note that the call-back function will be called from the timer task. So it will not have the usual stack and priority of your own task.
- Construct your own timer using these functions:
- Create your own TC interrupt. This is probably what you call a hardware-timer. This can give the best time resolution.
/* Send a message to the task to unblock it. */
< EDIT >
Use one of these solutions: TaskNotify or
QueueSend
< EDIT >
vTaskNotifyGiveFromISR( xEMACTaskHandle, &xHigherPriorityTaskWoken )
xQueueSendFromISR( xMyQueue, pxItem, &xHigherPriorityTaskWoken );
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}
void vMyTask( void *pvParameters )
{
for( ;; )
{
/* No events to process now, wait for the next. */
< EDIT >
Use one of these solutions: either TaskNotify
or use a queue, not both.
< EDIT >
ulTaskNotifyTake( pdFALSE, ulMaxBlockTime );
xResult = xQueueReceive( xMyQueue, pvBuffer, ulMaxBlockTime )
if( xResult != pdFALSE )
{
/* TC3 expired: do something urgent. */
}
}
}
~~~~~
It is not recommended to write a lot of code within an ISR. It is best to wake-up (unblock) a task. The latency (the time between the ISR and the task waking up) is very short, normally much less than a ms. Again: unless your CPU is busy running higher-priority tasks.
These are just some examples, the choice is yours.
Regards.