I currently developing a gpio based kernel module for a custom protocol. As per requirements of protocol, I have to send data, clock and enable signal to output device throgh gpio. This data is 16-bit. For sending any new data the enable signal first goes high. Then, data is sent 1 by 1 bit, at every negative edge(High to low) of clock. After sending all 16-bits, the clock signal is stopped and enable signal goes low.

I have successfully developed this protocol with FriendlyARM mini2440. At that time I have used one of timers and setup its irq. In its service routine, I have sent the data 1 by 1 bit.

I am currently doing same thing in Raspberry pi. I have read the Datasheet of BCM2825 and it says it has 4 system timers. But, seaching through the Rpi-forums, I found that Rpi uses system timer 0,2 and 3. So, only one sytem timer 1 is remaining which I want to utilize. I could not figure out how to setup system timer on Rpi. Has any one used it in kernel module? Then please help.

Instead of writing kernel module, if I would patch linux kernel with xenomai patches, would it be easy task to setup a periodic timer and send data through it timer interrupt routine?

Any Suggestions?

1 Answer 1


If you don't mind patching the kernel with Ingo Molnar's RT-Preempt Patch or Xenomai you should be able to achieve very good scheduling precision even in userspace, simply enabling High Resolution Timers (HRT) and using clock_nanosleep().

In this way your userspace application should be able reach the sub-millisecond resolution, and you won't have to do a lot of kernel debugging while writing your kernel module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.