joan2937 / pigpio

pigpio is a C library for the Raspberry which allows control of the General Purpose Input Outputs (GPIO).
The Unlicense
1.45k stars 407 forks source link

C pigpio timer inaccuracy on raspbery pi 4 with raspian #594

Open nhunder opened 9 months ago

nhunder commented 9 months ago

Hello there, I am using the pigpio C library and tried to figure out what accuracy the timerfunctionality has with the following code:

Screenshot 2023-12-17 154328

the output of the code looks something like this with everything in microseconds:

625 375 0 250 500 375 376 624 250 375 500 375 625 500 125 500 125 750 375 250 625 500 375 251 624 500 375 125 250 375 500 250 375 375 250 250 0 375 750 750 500 750

does anybody know where this inaccuracy n*125us for every timer interrupt come from. i aasume it has something to do with kernel and the interrupt priority of the timerinterrupt, because i noticed under heavy load of the OS the inaccuracy becomes bigger.

And do you know if there is a possibility to get a more reliant timer with this library?