I have a Raspberry Pi Zero W that uses this LCD screen, including its touch interface using SPI0.

What I am trying to achieve is to add another SPI device that uses SPI0. I am able to successfully extend the SPI0 CS signals using an overlay, as described here in order to be able to add my SPI device to the RPi.

In order to test that I can use SPI0 while also using the abovementioned LCD, I am running the following test code, without the additional SPI device attached to the RPi:

import spidev
import time

spi = spidev.SpiDev()
spi.max_speed_hz = 10000
spi.mode = 0

msg = [0xAB]

while 1:
  res = spi.xfer2(msg)
  print("Result", res)

This returns [0] as the result for every transmission, which I assume means that the transfer was successful. Probing the signals used by SPI0 with an oscilloscope, I can verify that the corresponding CS and CLK signals are controlled as expected. I can see a clear signal on CLK, but there is no signal on MOSI. When I use the touch screen, I can see activity on the MOSI pin while communication between the LCD and RPi is taking place, so the SPI bus is certainly working - it is just as if I am missing something when I am trying to use the bus.

If I adapt the code to use SPI1, I am seeing the exact same symptom on the SPI1 pins, i.e. expected signals on CS and CLK, but no signal on MOSI (SPI1). Note that I have added dtoverlay=spi1-3cs to /boot/config.txt in order to activate SPI1.

Herewith also my /boot/config.txt:

# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border

# uncomment to force a console size. By default it will be display's size minus
# overscan.

# uncomment if hdmi display is not detected and composite is being output

# uncomment to force a specific HDMI mode (this will force VGA)

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display

# uncomment for composite PAL

#uncomment to overclock the arm. 700 MHz is the default.

# Uncomment some or all of these to enable the optional hardware interfaces

# Uncomment this to enable the lirc-rpi module

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)

# New line added 2022/09/30
hdmi_cvt 1024 600 60 6 0 0 0

# New line added 2022/10/10

What could be the reason for seeing no signal on the MOSI pins for either SPI0 or SPI1, while the expected signals on the CS and CLK pins appear?

Thank you in advance for your assistance!

UPDATE 1: Comment by joan:

Use piscope to capture the signals

Thank you Joan for referring me to piscope - that tool is a golden treasure! Below are the screenshots that I took using SPI0 and SPI1, as described in the original post above.



Interestingly, there seems to be data on the MOSI line only when the first byte is sent, thereafter there is nothing on the MOSI line. I did not confirm if the data on MOSI for this one byte is correct, though - I am just trying to first get the bus completely up and running.

What could cause the SPI bus to only transmit the data once, and never again after that?

Comment by Gil:

A schematic would be a big help, I do not do well with word problems. MOSI is Master Out Serial In. Is the device whos pin you are referencing expected to return data. If not it will not do anything

As explained in my original post, I don't have the external device connected yet, so there isn't a schematic that I can post at this stage. I am probing the MOSI pin on the RPi directly first to see if the RPi transmits data over the SPI bus. This will make it easier for me to first get the SPI bus running and then continue with further integration, instead of trying to debug a basic SPI bus issue with everything connected and possibly something else influencing my test results.

  • 1
    Use piscope to capture the signals.
    – joan
    Oct 11, 2022 at 20:14
  • A schematic would be a big help, I do not do well with word problems. MOSI is Master Out Serial In. Is the device whos pin you are referencing expected to return data. If not it will not do anything.
    – Gil
    Oct 11, 2022 at 22:12
  • You are only sending one byte (0xAB) per transmission. If you want to send multiple bytes per transmission send an array, e.g. [0, 1, 2, 3, 4].
    – joan
    Oct 12, 2022 at 8:32
  • @joan: Yes, I realize that, but in the loop in my code the same byte is supposed to be transmitted every second. Thus, I am expecting to see that one byte to be transmitted every time the CLK signal is active. Why is the one byte transmitted only once, when I am trying to transmit the same byte every second? Oct 12, 2022 at 11:03

1 Answer 1


The peculiar result is a peculiarity of Python.

The variable msg is being overwritten in the function call. Set it each time through the loop.

import spidev
import time

spi = spidev.SpiDev()
spi.max_speed_hz = 10000
spi.mode = 0

while 1:
  msg = [0xAB]
  res = spi.xfer2(msg)
  print("Result", res)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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