[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avrdude-dev] Win 32 port
From: |
Alex Shepherd |
Subject: |
RE: [avrdude-dev] Win 32 port |
Date: |
Fri, 13 Feb 2004 11:32:10 +1300 |
> > Here are a list of errors that I saw. Note that I got multiples of
> > these errors and most of the time the mismatch was at 0x0200. Funny
> > that it is always on a page boundary?
I had this exact same issue months ago using the parallel port interface
on Win2k.
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.
Anyway all this code is already in CVS a while ago in the ppiwin.c file.
I suggest that if you append these changes to you test Win32 API
version, the problem will go away. The code changes replace the library
version of usleep() - see code fragment below.
Hopefully this will make this problem go away. :)
Cheers
Alex Shepherd
================================================================
// WARNING WARNING This function replaces the standard usleep() library
function
// because it doesn't appear to delay for the correct time
#ifndef MIN_SLEEP_USEC
#define MIN_SLEEP_USEC 20000
#endif
unsigned usleep( unsigned int uSeconds )
{
struct timeval t1, t2;
struct timespec nanoDelay ;
if (usecPerfDelay(uSeconds))
return;
gettimeofday(&t1, NULL);
if( uSeconds > MIN_SLEEP_USEC )
{
nanoDelay.tv_sec = uSeconds / 1000000UL;
nanoDelay.tv_nsec = (uSeconds / 1000000UL) * 1000 ;
nanosleep( &nanoDelay, NULL ) ;
}
/* loop for the remaining time */
t2.tv_sec = uSeconds / 1000000UL;
t2.tv_usec = uSeconds % 1000000UL;
timeradd(&t1, &t2, &t1);
do {
gettimeofday(&t2, NULL);
} while (timercmp(&t2, &t1, <));
}
#endif