I tried it on both Raspi 3 and 2 using the SpiDev python library.

I've never even seen any kind of output on MOSI or CS lines with my oscilloscope.

Controlling an SH1106 OLED display via the luma.oled lib works however AND generates signals on the MOSI line.

Also, manually driving the GPIOs works just fine.

  • Nope, not there... – Tim W. Apr 7 '19 at 10:33
  • 1
    Show the code you use. Also try the following to confirm SPI works. sudo pigpiod then pigs spio 0 50000 0 then pigs spix 0 0xaa 0x55 and check on the scope. – joan Apr 7 '19 at 11:31

You might like to try my little test program, under GUI Desktop IDLE python. Or run under terminal mode with sudo.

rpi3b+ python spi

# spi_test05 tlfong01 2019apr07hkt2043 ***

# Computer = Rpi3B+
# Linux    = $ hostnamectl = raspberrypi Raspbian GNU/Linux 9 (stretch) Linux 4.14.34-v7+ arm 
# Python   = >>> sys.version = 3.5.3 Jan 19 2017

# Test 1   - repeatSendByte() - SPI port repeatedly send out single bytes.  
# Function - Repeat many times sending a byte, pause after each byte.

# Test 2   - loopBackTest()   - SPI port send and receive one byte.
# Function - Send one byte to MSOI and read it back from MISO. 
# Setup    - Connet MOSI pin to MISO pin to form a loop.

from   time import sleep
import spidev

spiPort0 = spidev.SpiDev()
spiPort0.max_speed_hz = 100000

def spiSendRecvOneByte(spiPort, sendByte):
    sendByteArray = [sendByte]
    recvByteArray = spiPort.xfer(sendByteArray)    
    return recvByteArray

def repeatSendOneByte(spiPort, sendByte, pauseTimeBetweenBytes, repeatCount):
    print('\nBegin repeatSendByte(),....')
    for i in range(repeatCount):
        spiSendRecvOneByte(spiPort, sendByte)
    print('End   repeatSendByte().')

def loopBackOneByte(spiPort, sendByte):
    recvByteArray     = spiSendRecvOneByte(spiPort, sendByte)
    recvByte          = recvByteArray[0]

    print('\nBegin testLoopbackOneByte(),....')
    print('      sendByte  = ', hex(sendByte))
    print('      recvByte  = ', hex(recvByte))
    print('End   testLoopbackOneByte(),....')

def testRepeatSendOneByte():
    repeatSendOneByte(spiPort0, 0x5b, 0.0001, 20000000)

def testLoopbackOneByte():
    loopBackOneByte(spiPort0, 0x5b)


''' Smple output tlfong 01 2019apr07hkt2047
Begin testLoopbackOneByte(),....
      sendByte  =  0x5b
      recvByte  =  0x5b
End   testLoopbackOneByte(),....

# *** End ***


Appendix A - Rpi SPI pinout

SPI pinout

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.