[SOLVED] Not able to read SPI signal from Arduino Uno with digital oscilloscope

Hi all,

I’m trying to connect my arduino uno to an external SPI device. Before doing this, I want to study SPI signal coming out from MOSI pin when running a simple testing sketch I created.

The problem is that I cannot see any signal coming out from pin 11 (MOSI). All I can see is a fixed signal at 5v. This is the same result I obtain if I connect the oscilloscope probe to other SPI pins, like SCK and Slave Select pin.

I’m new to oscilloscope so probably I’m doing something wrong setting it.

My scope is a Siglent SDS1000DL (您要找的页面走丢了-深圳鼎阳科技公司). It is new and it is working fine, since I tested it with other simple signals. Its sample rate is 250 MS/s and the analog bandwidth is 25 MHz.

My sketch tries to transmit a decimal digit on the MOSI pin. From what I understood when I transmit a decimal digit on the wire, for example ‘10’ (in binary it is ‘1010’), I should see on the scope an impulse whose amplitude is 5V (the first logical ‘1’), then the signal should fall down to 0V (the second binary ‘0’), then again an impulse at 5V (the third logical ‘1’) and in conclusion the last ‘0’.

For this reason, I set the Volt/div parameter to 5V, in order to have a logical ‘1’ on the wire displayed as high as a single screen vertical division. The clock frequency of the spi test signal should be 500 kHz, since I used SPI.setClockDivider(32); so 16 MHz / 32 = 500kHz. By the way, 500 kHz is a period of 2 µs. I am wondering if setting sec/div to 2 µs has sense. My scope screen has 15 horizontal divisions. According to Nyquist, the minimal sample rate to have a reliable digital measurement in my case should be 1 MHz but, in practice, I need at least a 4x faster sample rate, so 2 MHz should be fine. If so, my scope specifications are adequate for my purpose.

This is my sketch:

// include the SPI library:
#include <SPI.h>

// set pin 10 as the slave select for the digital pot:
const int ss = 10; // slave select pin
const int del=1000; // delays between spi transmissions
const int digit = 10;
const int divider = 32;

void setup() {
  // set the slaveSelectPin as an output:
  pinMode (ss, OUTPUT);
  // initialize SPI:
  SPI.begin(); 
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(divider);
}

void sendValue(int value)
{
  digitalWrite(ss, LOW);
  SPI.transfer(value); // send digit 10 on the wire
  digitalWrite(ss, HIGH);
}

void loop() {
  
  sendValue(digit);
  delay(del);
  sendValue(0);
  
}

So, what can I do in order to see my signal on the scope? Do I have to change to scope configuration or my sketch is wrong?

Thank you in advance,

Daniele

..what is your Trigger mode setting? You may go with higher sec/div in case your SPI clock settings is for higher speeds, then you just go down to see a "byte".. Try to sync with SS signal, falling edge..

Hi,

thank you for the prompt reply.

Eventually I was able to read the signal with my scope.

It was a triggering-level-related problem. My trigger level was too low in order to see something (default settings). From my tests the correct triggering level to see spi signals on arduino is between 1.00V and 4.60V. The Volt/div parameter is set to 5V and the sec/div knob is on the µs scale, otherwise the signal will be too compressed on the screen.