linux kernel - do_gettimeofday() in Beaglebone giving wrong time -
I'm trying to measure the length of a square wave on the Angstrom OS running the beagle bone. I have written a kernel driver to register an ISR in which I am spending time in pulses, everything is working fine, but the time gap is being measured is completely wrong. I am using the do_gettimeofday () function to measure time when I do the same using the voting () function in the userspace program, I am able to get the right value (this is approximately 1007 us a 1000us wave ), But when I use the driver to measure the pulse, then I get the gap between 1923us. I do not know why the time interval in the kernel is more than the user location. I've attached my code below if someone can make a mistake in my program then I would be grateful.
kernel ISR:
static irqreturn_t ISR (int irq, zero * dev_id) {prev = c; Do_gettimeofday (& amp; c); Printer (KERN_ALERT "% ld", (c.tv_usec - prev.tv_usec)); Return IRQ_HANDLED; } Userspace handling:
while (1) {prev = start; Gettimeofday (and start, tap); RC = election (and FDset, 1, 20000); If (RC & lt; 0) {printf ("Error in RC \ n"); Return -1; } If (RC == 0) {printf ("timeout \ n"); Return -1; } If (fdset.revents and POLLPRI) {len = read (fdset.fd, buf, 2); Printf ("% ld \ n", (start.tv_usec - prev.tv_usec)); }}
For the outline of delay, I'm lazy and useful Set up a GPIO pin, then measure time with an oscilloscope. Probably not the answer you want, but it can help you more than the obstacle.
Comments
Post a Comment