What I'd like to do is to create an interrupt one a timer expires after 1 ms ... 100 ms. It doesn't even have to be very accurate.

Working with microcontrollers I'm used to start a timer say in main() and get an interrupt when it expires.

But how do I set this up with the Raspberry Pi? I'm using WiringPi but so far I haven't found how to do this.

I'd be happy to get some insights on this. Thank you very much.

  • The Raspberry Pi is a Linux box. Just like any other Linux box as far as Linux timing is concerned. Have you checked a Linux site?
    – joan
    Commented Oct 14, 2014 at 16:58
  • Among others I've tried this: gnu.org/software/libc/manual/html_node/Setting-an-Alarm.html But for some reason I didn't get it to run.
    – Soeren
    Commented Oct 14, 2014 at 17:16

1 Answer 1


The wiringPi library provides a number of blocking timer calls. One is used for micro second granularity (delayMicroseconds) and the other is used for milli second granularity (delay). See:


Using either of these, you can block your C program for a configurable amount of time. For example, if you need to send a pulse every 50 milli seconds, you could code:

   // Code to send a pulse

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.