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?
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:
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?