Visit Jeremy's Blog.
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 11-13-2009, 11:36 PM   #1
LQ Newbie
Registered: Nov 2009
Posts: 4

Rep: Reputation: 0
Help On RTC !

Is it possible to turn on periodic interrupt for RTC from a kernel module ? We can do it from user space using 'RTC_IRQP_SET' and 'RTC_PIE_ON' options. But what about turning it on from kernel module?
Old 11-14-2009, 10:37 AM   #2
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,892
Blog Entries: 27

Rep: Reputation: 2183Reputation: 2183Reputation: 2183Reputation: 2183Reputation: 2183Reputation: 2183Reputation: 2183Reputation: 2183Reputation: 2183Reputation: 2183Reputation: 2183

You should read the rest of the 'man rtc'.

'RTC' management is very important so the use of handler/API are preferred;

excerpt 'man rtc';

/dev/rtc, /dev/rtc0, /dev/rtc1, etc: RTC special character device files.

/proc/driver/rtc: status of the (first) RTC.

When the kernel's system time is synchronized with an external reference using adjtimex(2) it
will update a designated RTC periodically every 11 minutes. To do so, the kernel has to briefly
turn off periodic interrupts; this might affect programs using that RTC.

An RTC's Epoch has nothing to do with the POSIX Epoch which is only used for the system clock.

If the year according to the RTC's Epoch and the year register is less than 1970 it is assumed to
be 100 years later, that is, between 2000 and 2069.

Some RTCs support "wildcard" values in alarm fields, to support scenarios like periodic alarms at
fifteen minutes after every hour, or on the first day of each month. Such usage is non-portable;
portable user space code only expects a single alarm interrupt, and will either disable or reini-
tialize the alarm after receiving it.

Some RTCs support periodic interrupts with periods that are multiples of a second rather than
fractions of a second; multiple alarms; programmable output clock signals; non-volatile memory;
and other hardware capabilities that are not currently exposed by this API.

date(1), adjtimex(2), gettimeofday(2), settimeofday(2), stime(2), time(2), gmtime(3), time(7),
hwclock(8), /usr/src/linux/Documentation/rtc.txt
You should look at '/usr/src/linux/Documentation/rtc.txt' to gain some insight. If you want to work at the kernel level then I suggest that you look at 'Linux Kernel Parameters' & 'Linux Device Drivers, Third Edition'.

The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!
Old 11-21-2009, 12:26 AM   #3
LQ Newbie
Registered: Nov 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Hi there..........,

Thanks Gary !

I turned on periodic interrupt from user space and loaded a kernel module with my ISR for RTC interrupt. What i need exactly is to execute my ISR on each RTC interrupt. But i couldnt find it working. I am attaching the code herewith. Any suggestions on what went wrong ?

irqreturn_t my_irq_handler(int irq, void *dev_id, struct pt_regs *regs)

printk("Inside ISR for IRQ 8,\n");


int init_module(void)
printk("<1>Hello World\n");

request_irq(8, my_irq_handler, IRQF_SHARED,"test", NULL);

return 0;


void cleanup_module(void)
printk("<1>GoodBye World\n");
free_irq(8, NULL);



int main()
int fd,retval,freq,i=1;
unsigned long temp,data;

freq= 2;
ioctl(fd, RTC_IRQP_SET, freq);

/* Enable periodic interrupts */
ioctl(fd, RTC_PIE_ON, 0);

/* This blocks */
retval = read(fd, &data, sizeof(unsigned long));
if (retval == -1)
fprintf(stderr, " %d",i);



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
Help On RTC ! anniedeepa Member Intro 0 11-13-2009 11:02 PM
RTC . raajeshjt Linux - Embedded & Single-board computer 1 11-05-2009 08:39 PM
RTC . raajeshjt Linux - Embedded & Single-board computer 1 11-03-2009 03:22 PM
RTC Alarm wakes up, even while BIOS has RTC alarm disabled mastermind2501 Linux - Newbie 2 12-22-2008 04:32 PM
Problem with rtc rogerscuall Linux - Software 0 08-09-2007 11:40 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:58 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration