SPI interference

Hello,

I have hard time to run SPI on Arduino UNO. Arduino is connected to RPI4 via SPI, Arduino's serial port is attached to external Motor driver and I2C is connected to Arduino mini for sensor reading. Basic logic is that after motor starts running, Arduino Uno waits for interrupt on PIN2. When this happens, Arduino Uno sends serial command to Motor driver to stop, Uno gets sensor data via I2C and turn on the pin 8 to signal RPI end of cycle. When RPI receives signal via pin 8 from Arduino, it starts SPI communication with Arduino. And here is the problem. SPI blocks itself and data are corrupted. However, if I start SPI communication only 2 seconds after signal from Arduino pin 8, than everything is OK. What can be the cause?

Thank you

isacsk:
And here is the problem. SPI blocks itself and data are corrupted. However, if I start SPI communication only 2 seconds after signal from Arduino pin 8, than everything is OK. What can be the cause?

Please tell SPI is connected between Arduino UNO and what. And tell which side fails to send the SPI data.

..Arnav

SPI is a connection.between RPI4 amd Uno with RPI as master. Uno gets stucked after SPI transfer and is not able to function than only after reset. I2C and serial connection look OK only SPI gets stucked. What is surprising for me is the fact that this happens only in first two seconds after motors are stopped. If I start SPI after two seconds it functions normally.

Then add a delay to your code to give it 2.5 seconds.

:smiley: of course but this is not normal. Something interferes with spi and I would like to know what it is