[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avrdude-dev] Win 32 port
From: |
Jan-Hinnerk Reichert |
Subject: |
Re: [avrdude-dev] Win 32 port |
Date: |
Fri, 13 Feb 2004 01:07:21 +0100 |
User-agent: |
KMail/1.5.4 |
On Thursday 12 February 2004 23:32, Alex Shepherd wrote:
> I had this exact same issue months ago using the parallel port
> interface on Win2k.
The performance counter is used in usecPerfDelay() which you haven't
included below ;-)
I believe that it is best to use this code on machines that do support
it.
The fallback mechanism below uses gettimeofday() and nanosleep().
AFAIK, these are not available without cygwin ;-(
> The issues tuned out to me that the timers were not delaying long
> enough. The solution I finally found was to poll the Pentium 64 bit
> CPU performance counter for the shorter duration delays.
Have you found out, in what way the sleep fails?
While we are at it, I have a few questions regarding the code?
> if( uSeconds > MIN_SLEEP_USEC )
> {
> nanoDelay.tv_sec = uSeconds / 1000000UL;
> nanoDelay.tv_nsec = (uSeconds / 1000000UL) * 1000 ;
This seems to be wrong. It will evaluate to 0 for all values below 1s.
IMHO it should be
nanoDelay.tv_nsec = (uSeconds % 1000000UL)*1000 ;
> nanosleep( &nanoDelay, NULL ) ;
> }
However, we could drop this anyway, since only some erase-delays are
greater than 20ms.
The whole gettimeofday()-idea (which is also in "avr.c" now) could
have a small problem.
The delay can get shorter by the granularity of the timer (if the
timer tick appears directly after the first read). This is only a
problem, if timer resolution is too coarse.
It would be safe, if we read the value until it changes and do the
delay from that point. This could get quite slow on machines that
have to use the fallback-mechanism (Are there still people using
pre-pentium machines?)
Windows' Multimedia-timers look quite promising. However, the
documentation is quite vague about the minimum resolution for
particular win32-variants. Also, I can't tell how accurate these
timers are...
Cheers
Jan-Hinnerk