Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-12-2012, 01:07 AM   #1
LQ Newbie
Registered: Jun 2012
Posts: 2

Rep: Reputation: Disabled
Question 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?
Old 06-13-2012, 09:00 PM   #2
Senior Member
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
hrtimer dennisdd Programming 22 05-16-2012 10:30 PM
Issue with 'tg3' module with the kernel-2.6.18-274.3.1.el5 dezavu Linux - Kernel 2 10-12-2011 03:21 AM
kernel module compilation issue daff_vadi Linux - Kernel 4 07-15-2010 05:52 AM
fedora 8 livecd kernel module issue AutoC Fedora 1 02-16-2009 07:53 AM
e1000 module issue on kernel 2.6.10 blizzardtweaker Slackware 23 01-05-2005 06:39 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:07 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration