I want to write a C program that runs some code at a fixed interval (somewhere between 200us and 1ms, TBD). Is it possible to use the hardware timer interrupts to execute code without resorting to writing a kernel driver? I'm hesitant to use any delay functions since that doesn't always ensure that the code fires off at a fixed interval. (The period is the delay PLUS the time it takes to execute the rest of the code, which may vary).

I saw that the WiringPi library allows you to attach code to a GPIO interrupt, but I didn't see anything about a timer. I would ideally like to do something similar with a timer interrupt.


  • Hello and welcome to Raspberry Pi! Please take the tour and visit the helpcenter to see how things work here. This answer provides some results that might be relevant to your endeavour - while it addresses GPIO events, the same underlying mechanisms will be important for timer interrupts. – Ghanima Feb 13 '19 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.