nravanelli wrote:I have yet to find the answer to this.... Would I be able to use I2C and SPI communication on the Pi simultaneously? Reason: I have a DeltaSigmaPi (https://www.abelectronics.co.uk/product ... a-Sigma-Pi) which works of I2C and am looking into a Pi TFT screen which works over SPI... would this cause any problems? They would be over different pins... correct?
I'm trying to do the same thing on my pi, but I'm having issues with the I2C running correctly while running the SPI as well. What clock rates are you running the SPI and I2C interfaces at? Is each interface running in a separate thread or executable? I have to run the SPI interface at 8Mhz for one device, but I leave the I2C device clocked at the default 100kHz.Richard-TX wrote:I2C and SPI are on different pins and yes you can use both at the same time. I have done it myself.
The SPI and I2C clock rates are independent and the actual transfers are handled by dedicated hardware. It makes no difference if you run separate threads or not.Donny3000 wrote:I'm trying to do the same thing on my pi, but I'm having issues with the I2C running correctly while running the SPI as well. What clock rates are you running the SPI and I2C interfaces at? Is each interface running in a separate thread or executable? I have to run the SPI interface at 8Mhz for one device, but I leave the I2C device clocked at the default 100kHz.Richard-TX wrote:I2C and SPI are on different pins and yes you can use both at the same time. I have done it myself.
That's what I had figured, but I wasn't sure because if I run both of my executables at the same time my I2C readings goes to hell. If I don't run my SPI and I2C executables simultaneously, but run them independently, then they run perfectly (reading data at the rates they are configured without data corruption). But, if I start my I2C executable first and then start my SPI executable, the I2C readings come through corrupted or don't come through at all. Although, the SPI readings come through fine. So I was trying to see if anyone has experienced this as well.joan wrote:The SPI and I2C clock rates are independent and the actual transfers are handled by dedicated hardware. It makes no difference if you run separate threads or not.Donny3000 wrote:I'm trying to do the same thing on my pi, but I'm having issues with the I2C running correctly while running the SPI as well. What clock rates are you running the SPI and I2C interfaces at? Is each interface running in a separate thread or executable? I have to run the SPI interface at 8Mhz for one device, but I leave the I2C device clocked at the default 100kHz.Richard-TX wrote:I2C and SPI are on different pins and yes you can use both at the same time. I have done it myself.
Code: Select all
spi_lock=threading.Lock()
def readx():
values=None
with spi_lock:
spi.open(...
values=spi.xfer(...
spi.close(...
return values