I have been testing this timer using the example code, and find the
speed, at least on the 7260 I have to be close to 983.285 Khz. Also,
I also created a similar macro that gives micro-seconds instead of
mili-seconds:
#define FRTimerToUs(A) (((unsigned long long) A) * 1000000ULL /
983285ULL)
I however am not finding much error in the gettimeofday() and usleep()
functions though. I am using these to process a loop at regular
intervals. I use gettimeofday() to determine how many micro-seconds I
need to wait for the next cycle (to compensate for processing time),
then use usleep() to wait the number of microseconds needed. Using the
example code I found here, and adjusting for the actual frequency of
the timer, I am getting less than 50 micro-second variation in my
loops as shown below. The first number is from the free running timer,
the second is from gettimeofday().
loop time: 999658 (us), 1000000
loop time: 1000006 (us), 1000000
loop time: 1000006 (us), 1000000
loop time: 1000009 (us), 1000000
loop time: 1000361 (us), 1000000
loop time: 999653 (us), 1000000
loop time: 1000008 (us), 1000000
loop time: 1000006 (us), 1000000
loop time: 1000009 (us), 1000000
loop time: 1000366 (us), 1000000
loop time: 999647 (us), 1000000
loop time: 1000009 (us), 1000000
loop time: 1000007 (us), 1000000
loop time: 1000007 (us), 1000000
loop time: 1000366 (us), 1000000
loop time: 999649 (us), 1000000
loop time: 1000008 (us), 1000000
loop time: 1000006 (us), 1000000
I need to know the time between loops fairly exactly so I can read the
counter on the xdio, and calculate the speed of the train every second
with reasonable precision.
Well, I am headed to the beach tomorrow and will not be able to reply
for 5 days or so. We get two weeks for Easter here in Mexico!!
Don.
--- In "Eddie Dawydiuk" <> wrote:
>
> Hello,
>
> > If I am reading this right, this will increase the resolution of
> > gettimeofday from 10,000 usec to < 1,000 usec... Is that right?
>
> Correct.
>
> > I have an encoder that can generate > 20 pulses in 10,000 usec....
> > Is there any way to time stamp these pulses so I know the interval?
>
> The best way to do this is to use the 40bit debug timer, it runs at
> 983Khz. The gettimeofday() unfortunately is not very accurate.. Its
> supposed to interpolate time between clock ticks but the ep93xx
> Linux port doesn't yet do this(Jesse's NetBSD port does though).
>
> Another option would be to use the TS-7260, the XDIO can create up to
> 14.7Mhz free running counter.
>
> //Eddie
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|