Hello Forum!
I’m here to get some advice about SPI Communication between Arduino UNO & Jetson Nano.
I already checked my Jetson Nano activated SPI pins with ‘Local Loop Test’.
After I got HW-209 8 channel Level Shifter, I connect two devices like the picture below;
After setup, I used the code below;
Master Code
import spidev
spi = spidev.SpiDev()
spi.open(0,0)
spi.max_speed_hz = 10000
received_data = spi.xfer2([0x01])
print(received_data)
Slave Code
#include <SPI.h>
volatile byte receivedData;
volatile bool dataReceived = false;
void setup() {
pinMode(MISO, OUTPUT);
SPCR |= _BV(SPE); // Enable SPI in slave mode
SPI.attachInterrupt(); // Enable interrupt
}
ISR(SPI_STC_vect) {
receivedData = SPDR; // Read received data
SPI.transfer(receivedData); // Send the same data back
dataReceived = true;
}
void loop() {
if (dataReceived) {
// Process the received data if needed
dataReceived = false;
}
}
If the connection okay, Master will receive [1], but the received_data has random value when I run the code.
I thought it has some problems on devices, so I tried same setting on Raspi 4B.
As the result, Raspi 4B worked pretty well…
So, I REALLY REALLY need HELP to solve this problem…
Jetson Nano Dev Kit 4GB
Jetpack version 4.6.5
Python 3.6.9
Below pictures is the real setup that I did on real-world.