go-rpio icon indicating copy to clipboard operation
go-rpio copied to clipboard

Interrupt/event based edge detection

Open wjessop opened this issue 1 year ago • 1 comments

I'm trying to detect a pulse on a GPIO pin (the tacho from a fan). Right now I have to poll, something like this:

for {
  if rpmPin.EdgeDetected() {
    doTheThint()
  }
}

This busy loop takes 100% of a CPU core. I can add a sleep in there but at 10k pulses per minute the sleep has to be small and the program still uses a lot of CPU. Would it be possible to use some sort of hardware based interrupt notification for edge detection to ease the load on the CPU?

wjessop avatar Sep 06 '23 14:09 wjessop

this information/link might be useful https://www.i-programmer.info/programming/hardware/14114-raspberry-pi-iot-in-c-events-a-interrupts.html?start=1

peritonow avatar Oct 17 '23 13:10 peritonow