Ejemplo n.º 1
0
int test_time(int argc, char *argv[])
{
	hrt_abstime h, c;
	int64_t lowdelta, maxdelta = 0;
	int64_t delta, deltadelta;

	/* enable the cycle counter */
	(*(unsigned long *)0xe000edfc) |= (1 << 24);    /* DEMCR |= DEMCR_TRCENA */
	(*(unsigned long *)0xe0001000) |= 1;    	/* DWT_CTRL |= DWT_CYCCNT_ENA */

	/* get an average delta between the two clocks - this should stay roughly the same */
	delta = 0;

	for (unsigned i = 0; i < 100; i++) {
		uint32_t flags = px4_enter_critical_section();

		h = hrt_absolute_time();
		c = cycletime();

		px4_leave_critical_section(flags);

		delta += h - c;
	}

	lowdelta = abs(delta / 100);

	/* loop checking the time */
	for (unsigned i = 0; i < 100; i++) {

		usleep(rand());

		uint32_t flags = px4_enter_critical_section();

		c = cycletime();
		h = hrt_absolute_time();

		px4_leave_critical_section(flags);

		delta = abs(h - c);
		deltadelta = abs(delta - lowdelta);

		if (deltadelta > maxdelta) {
			maxdelta = deltadelta;
		}

		if (deltadelta > 1000) {
			fprintf(stderr, "h %" PRIu64 " c %" PRIu64 " d %" PRId64 "\n", h, c, delta - lowdelta);
		}
	}

	printf("Maximum jitter %" PRId64 "us\n", maxdelta);

	return 0;
}
Ejemplo n.º 2
0
int test_time(int argc, char *argv[])
{
	hrt_abstime h, c;
	int64_t lowdelta, maxdelta = 0;
	int64_t delta, deltadelta;

	/* enable the cycle counter */
	(*(unsigned long *)0xe000edfc) |= (1 << 24);    /* DEMCR |= DEMCR_TRCENA */
	(*(unsigned long *)0xe0001000) |= 1;    	/* DWT_CTRL |= DWT_CYCCNT_ENA */

	/* get an average delta between the two clocks - this should stay roughly the same */
	delta = 0;

	for (unsigned i = 0; i < 100; i++) {
		uint32_t flags = irqsave();

		h = hrt_absolute_time();
		c = cycletime();

		irqrestore(flags);

		delta += h - c;
	}

	lowdelta = abs(delta / 100);

	/* loop checking the time */
	for (unsigned i = 0; i < 100000; i++) {

		usleep(rand() * 10);

		uint32_t flags = irqsave();

		c = cycletime();
		h = hrt_absolute_time();

		irqrestore(flags);

		delta = abs(h - c);
		deltadelta = abs(delta - lowdelta);

		if (deltadelta > maxdelta)
			maxdelta = deltadelta;

		if (deltadelta > 1000)
			fprintf(stderr, "h %llu  c %llu  d %lld\n", h, c, delta - lowdelta);
	}

	printf("Maximum jitter %lld\n", maxdelta);

	return 0;
}
Ejemplo n.º 3
0
dotime(void)
{
    int	index;

    cycletime();
    for ( index = 0 ; index < nname ; index += 1 ) {
	timepropagate( topsortnlp[ index ] );
    }
}
Ejemplo n.º 4
0
static
void
dotime(
void)
{
    unsigned long index;

	cycletime();
	for(index = 0; index < nname; index += 1){
	    timepropagate(topsortnlp[index]);
	}
}