This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Re: Timer mechanism
- From: "Gary Thomas" <gary at mlbassoc dot com>
- To: "Giovanni Perbellini" <perbellini at sci dot univr dot it>
- Cc: "Savin Zlobec" <savin at elatec dot si>, ecos-discuss at sources dot redhat dot com
- Date: Wed, 14 Jan 2004 08:20:39 -0700 (MST)
- Subject: Re: [ECOS] Re: Timer mechanism
- References: <400543A1.4010301@elatec.si> <007801c3daa2$c9ca95c0$85f21b9d@CDC03>
Giovanni Perbellini said:
>
>
>
>> >Hi all,
>> >
>> >I'd like to know how the timer mechanism works.
>> >I have used a function to return the current time, cyg_current_time().
>> >I guess that this function returns the ticks count since when I turn on
> the
>> >board, is it correct?
>> >
>> >
>> Yes - since eCos started.
>
> Ok, but why do I get a very big number, even if I execute the
> cyg_current_time() when the eCos starts?
Did you remember to include <cyg/kernel/kapi.h>? If not, you'll
have troubles because cyg_current_time() returns a long long value
and your code will be expecting only a long - hence gobbledygook.
>
>> >Otherwise, Is there a variable, method or class returning/containing the
>> >ticks count since the power up?
>> >
>> >Moreover, I have read that there is a macro to read the current value of
> the
>> >timing devices counter since the last interrupt, called HAL_CLOCK_READ.
> What
>> >is the relationship between the tick and interrupt?
>> >
>> The timing device is usually a hardware timer which can generate an
>> interrupt after a
>> specified amount of internal ticks. This timer gets initialized with
>> HAL_CLOCK_PERIOD
>> which "is" 10ms (by default) in hw timer ticks. The HAL_CLOCK_READ macro
>> returns
>> the number of hw timer internal ticks elapsed since the last interrupt.
>
> Is HAL_CLOCK_PERIOD the time between two interrupts or two internal ticks?
These should normally be the same. HAL_CLOCK_PERIOD should represent the
value given to your timer hardware to create a single system tick, which
is 10ms by default.
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss