SPI Setup Problem between Arduino UNO & Jetson Nano

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.



Hi jeyong8217,

Are you using the devkit or custom board for Jetson Nano?
What’s your Jetpack version in use?

Could you refer to the following thread to verify SPI loopback test on Jetson Nano before connecting to Arduino board?
Jetson Nano SPI Bus Not Working - #10 by KevinFFF

I’m using Jetson Nano Dev Kit 4GB Ram B01 with Jetpack 4.6.5

I already followed the post that you hyperlinked.

I checked my device successfully got the correct result among local loop test.
But, as I mentioned above, it does not well receive the data which gave me random number but the correct one is [1].

Okay, it seems the issue come up after you connect with the Arduino UNO.
Have you confirm the level is the same for both Jetson Nano and Arduino UNO?
1.8V or 3.3V?

Are you using Jetson Nano as SPI master and Arduino UNO as SPI slave?

Could you get a scope to check the waveform at this moment?

I checked that Arduino Uno use 5V for logic level, and Jetson Nano use 3.3V.
To solve the difference of Logic Level, I bought HW-209 3.3V to 5V level shifter.

As I mentioned above, Raspi 4B worked well with the same setting, I think the level matched well.

Yes

I don’t know how to check the waveform but I have oscilloscope so I can try later.

Please use oscilloscope to check the waveform for MOSI and MISO and see where’s the unexpected data coming from.

Could you also try using spidev_test tool to verify?