Problem regarding the Timer API

View: New views
3 Messages — Rating Filter:   Alert me  

Problem regarding the Timer API

by Prasad.Nagapati :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi All,

I have one question regarding the Timers.

I want to use the timer in my application, there is certain condition
however.

An event is triggered (say UART) and I want to start the timer for this
event. But I don't know how much time it will take for the processing
that event. Once the processing is done I will get another trigger (from
UART) and I want to stop the timer. And I want to calculate the time
taken for the processing of this event.

Hence if I use any API's say NutTimerStart <group__xgTimer.html>  I have
to give the time in milliseconds but I don't know it in advance. Also if
I use NutTimerStartTicks <group__xgTimer.html>  again I have to give the
ticks in advance.
Please suggest me which API's I can use, if not how I should use the
timer for this particular case.

Thanks in advance
Prasad H N

_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: Problem regarding the Timer API

by Matthias Ringwald :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi

think of the "Timer" in Nut/OS as a tea timer. When the pre-set time  
is up, it rings, and your tea is ready.
To measure the time between two events, just record the system time  
when the first event occurs. Have a look at NutGetTime() or so.

m.

On 29.05.2009, at 10:32, <Prasad.Nagapati@...> wrote:

>
> Hi All,
>
> I have one question regarding the Timers.
>
> I want to use the timer in my application, there is certain condition
> however.
>
> An event is triggered (say UART) and I want to start the timer for  
> this
> event. But I don't know how much time it will take for the processing
> that event. Once the processing is done I will get another trigger  
> (from
> UART) and I want to stop the timer. And I want to calculate the time
> taken for the processing of this event.
>
> Hence if I use any API's say NutTimerStart <group__xgTimer.html>  I  
> have
> to give the time in milliseconds but I don't know it in advance.  
> Also if
> I use NutTimerStartTicks <group__xgTimer.html>  again I have to give  
> the
> ticks in advance.
> Please suggest me which API's I can use, if not how I should use the
> timer for this particular case.
>
> Thanks in advance
> Prasad H N
>
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion

_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: Problem regarding the Timer API

by uprinz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Prasad,

Two options:
If the timers granularity is good enough ( timer is 1ms and measurement
is 10s) you let the timer trigger a counter at the timer event.

If this is not enough, as you might need us or less granularity, you
should configure the timer of the CPU as a counter driven by the CPU
clock or any other more precise external clock. Then on the first event,
you reset the timer to 0 and on the second event you read out and reset
the timer again. In this case a backup throug an timer overflow counter
might help if the second event is unexpectedly long away and the timer
overflows.

I didn't look into the timer API from NutOS, but If you need to do high
speed or high efficiency things, it's always better to optimize your
software to the underlying hardware/CPU architecture for best results.

Regards, Ulrich

Prasad.Nagapati@... wrote:

> Hi All,
>
> I have one question regarding the Timers.
>
> I want to use the timer in my application, there is certain condition
> however.
>
> An event is triggered (say UART) and I want to start the timer for this
> event. But I don't know how much time it will take for the processing
> that event. Once the processing is done I will get another trigger (from
> UART) and I want to stop the timer. And I want to calculate the time
> taken for the processing of this event.
>
> Hence if I use any API's say NutTimerStart <group__xgTimer.html>  I have
> to give the time in milliseconds but I don't know it in advance. Also if
> I use NutTimerStartTicks <group__xgTimer.html>  again I have to give the
> ticks in advance.
> Please suggest me which API's I can use, if not how I should use the
> timer for this particular case.
>
> Thanks in advance
> Prasad H N
>
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion