-   Linux - Newbie (
-   -   HRTIMER issue in kernel module (

smrithytr 06-12-2012 01:07 AM

HRTIMER issue in kernel module
I am trying to write a kernel module where i want timers with microsecond precision. I am using HRTimers for the same.

linux version : linux v2.6.30 kernel compiled with hrtimer support

Processor : AT91SAM9260

HRTimer Initialization is as follows:
hrtimer_init( &hr_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL );

Using hrtimer as:
ktime = ktime_set(0, (long)(100000000)); /*100 milliseconds*/
hr_timer.function = &mrtu_reset_pulse
hrtimer_start( &hr_timer, ktime, HRTIMER_MODE_REL);

at91_set_gpio_value(AT91_PIN_PA6, 1);

Callback function:

static enum hrtimer_restart mrtu_reset_pulse(struct hrtimer *timer)
at91_set_gpio_value(AT91_PIN_PA6, 0);

When i set expiration time as 100 ms, hrtimer will expire after 110ms, and if i set expiration time as 96ms, hrtimer will expire after 100ms. How can i achieve microsecond precision using hrtimer?

PTrenholme 06-13-2012 09:00 PM

I just noticed your post and wondered if you'd found your answer. If you haven't, you might consider reposting to the "Programming" or "Kernel" sections. (Many people tend to skip posts in the "newbie" forum, since most of them are just "testing" or "hello" messages.)

As to your specific question, sorry, I non't have a clew, although the standard Linux kernels since 2.8 have included support for the HPET.

All times are GMT -5. The time now is 01:22 PM.