[ECOS] Re: Timer mechanism
Savin Zlobec
savin@elatec.si
Wed Jan 14 13:47:00 GMT 2004
Giovanni Perbellini wrote:
>
>
>
>>>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?
>
What is the version of eCos your are using and on what type of HW ?
I just ran the following code on the synthetic target:
while (1)
{
diag_printf("%d\n", cyg_current_time());
cyg_thread_delay(100);
}
and the output is:
0
100
200
300
400
500
600
700
800
900
1000
after 10 seconds.
>
>
>>>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?
>
HAL_CLOCK_PERIOD is the number of hw timer internal ticks between two RTC
interrupts. And it is a platform dependent value, because it depends on
the frequency of
hw timer.
savin
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
More information about the Ecos-discuss
mailing list