make calibration loop more tolerant for less accurate OS timers

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1378 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Arnim Läuger 16 years ago
parent 9ed3f7deea
commit f4b6109d1c

@ -1,3 +1,8 @@
2008-10-22 Arnim Laeuger <arniml@users.sourceforge.net>
* src/tap/cable/generic.c: make calibration loop more tolerant for
less accurate OS timers
2008-10-18 Kolja Waschk <kawk
* src/cmd/usleep.c, src/cmd/cmd.c, src/cmd/Makefile.am:

@ -32,7 +32,6 @@
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <assert.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>

@ -360,7 +360,7 @@ generic_set_frequency( cable_t *cable, uint32_t new_frequency )
cable->frequency = 0;
} else {
const double tolerance = 0.1;
const uint32_t loops = 2000;
uint32_t loops = 2048;
uint32_t delay = cable->delay;
uint32_t frequency = cable->frequency;
@ -375,13 +375,22 @@ generic_set_frequency( cable_t *cable, uint32_t new_frequency )
long double start, end, real_frequency;
cable->delay = delay;
start = frealtime();
start = frealtime();
for (i = 0; i < loops; ++i) {
cable->driver->clock(cable, 0, 0, 1);
}
end = frealtime();
assert(end > start);
if (end < start) {
printf( _("calibration error, wall clock is not monotonically increasing\n") );
break;
}
if (end == start) {
/* retry with higher loop count
if the timer is not fine grained enough */
loops *= 2;
continue;
}
real_frequency = (long double)loops / (end - start);
printf("new real frequency %Lg, delay %u\n",
real_frequency, delay);

Loading…
Cancel
Save