3

I have a zero W powered via USB from a laptop. I have setup up for the SPI drivers and run a very simple test program which is:

import spidev  
import time  
spi = spidev.SpiDev()  
spi.open(0, 0)  
spi.max_speed_hz = 500000  
spi.mode = 0  
try:  
    while True:  
        resp = spi.xfer2([0xAA])  
        time.sleep(0.1)  
except KeyboardInterrupt:  
    spi.close()  

I get the correct output but the waveforms are so noisy. Figure 1

SCLK and CE0
The yellow is the SCLK pin, the red is the CE0 pin

In figure 2:
SCLK and MOSI

The yellow is the SCLK pin and the red is the MOSI outputting one byte of 0xAA
The voltages are between 0 and 3.3. I looked at this because I can not receive data by the slave, but there could be a hundred reasons for that. What I would like to know, is this noise level normal and could it affect the slave device.
Many thanks.

Ingo
  • 42,961
  • 20
  • 87
  • 207

1 Answers1

3

These look like signals which have travelled along quite long wires with no termination, which were packed together. Using shorter wires and running SPI signals in a flat cable with GND lines in between signal lines will help. Adding a 30 Ohm series resistor on the CLK line (near the master pin which drives it) could be the next step.

Even then, your signals look acceptable and I wouldn't spend time on getting them super-clean as long as everything works, unless your ultimate plan is to run SPI at a much higher frequency. Your slave not receiving the data is almost certainly due to something else: noise would rather make it receive incorrect data.

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147