This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RE: timer
- To: mekala natarajan <mekala_natarajan at yahoo dot com>
- Subject: RE: [ECOS] timer
- From: Gary Thomas <gthomas at cambridge dot redhat dot com>
- Date: Tue, 15 May 2001 06:39:06 -0600 (MDT)
- Cc: ecos-discuss at sources dot redhat dot com
- Organization: Red Hat, Inc.
On 15-May-2001 mekala natarajan wrote:
> Can someone tell me the timer chip(and clock
> frequency) that is used in MBX kit.
>
> (eg.,For i386 pc target, the timer chip is 8254 whose
> clock frequency is 1193180HZ, from which we derive at
> the kernel clock of 10ms.)
>
> Basically i want to run my application within a time
> frame of 2ms(which is less than a tick).Within this
> 2ms frame, i need to get the current time at various
> points of the frame which will be in terms of
> microseconds.But ecos get current time system call
> will return time in terms of ticks. For this to happen
> i reduced the tick resolution to 500us. But with this
> configuration performance is degrading, since most of
> time is getting wasted in processing the interrupt.
>
> Now i don't want to use the kernel clock.
>
> How can i solve this problem.
>
> Can i directly access the timer chip and derive the
> desired periodicity from this.
>
> Is this possible?
>
> If yes.How can i do this?
>
The HAL_CLOCK_READ() will get you just what you want. It will
return the time (in hardware clock ticks) since the last system
clock timer interrupt. Thus it is a measure of time within the
current "tick" (heartbeat). You can easily convert the value
returned into us or ms.
Look at 'kernel/current/tests/tm_basic.cxx' for examples of how
to use it and how to convert the result into common units.