0

I am reading an ADC that signals when the data conversion is complete by setting the SPI MISO pin low. I would like to set an interrupt on that pin, but using the GPIO library to do so isn't working. If I try to simply attach an interrput using GPIO.add_event_detect, I get the error than the GPIO pin has not be set to an input. If I try setting it as an input, then attach hardware SPI (spi = spidev.SpiDev()) I don't seem to be getting the interrupt.

Does anyone have a good solution for attaching an interrupt on the MISO pin without interfering with the SPI?

4
  • 1
    I underrstand how SPI works. ADCs from Analog Devices use the MISO pin as their Rdy (ready) pin. When it goes low, you can read the data using spi.readbytes(3) without actually using spi.write. Data rates can be really high this way since nothing needs to be written to the client chip before getting the data. All I need is to get an interrupt on the MISO/RDY pin without messing up the spi configuration. The GPIO library as is will not let me do that. Does that make more sense now?
    – Scott
    Mar 15 at 16:59
  • I'm not sure how hardware tree "plays" with libgpiod, but have you tried one of the libgpiod "tools"; i.e. gpiomon? There's a man page for it - it sucks much like the rest of libgpiod, but it's the "way ahead" according to RPi pundits. You might have better luck with pinctrl - a RPi "product" written to fill the gap left by the brain-dead libgpiod. Sorry I can't help more - I've not done any interrupt handling on an RPi.
    – Seamus
    Mar 16 at 6:06
  • NOTE the additional detail you provided in a comment belongs in your question.
    – Milliways
    Mar 16 at 9:51
  • Which model Pi? pigpio will allow you to do what you want but only works on models prior to the Pi5 (the Pi5 uses different GPIO hardware).
    – joan
    Mar 16 at 11:48

1 Answer 1

0

The Raspberry Pi hardware supports SPI in master mode.
Whatever the device you are using does it does NOT appear to be acting as a normal SPI slave which requires an external clock.

The Linux kernel driver only supports standard SPI protocols.

If you want to use this device you will need to find a kernel driver which supports it (or more likely write your own custom driver).


You are mistaken if you think not sending data speeds SPI; it sends one bit per clock pulse and receives on the opposite phase of the same clock - delayed by half a clock cycle.
Normally if additional data input is expected you send dummy data to generate clocks.

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.