1

I am working with a SPI device on the Raspberry Pi 2, and am encountering an issue where the chip select line is asserting high mid-way through the transfer. Is this because the CS line is not pulled low hard enough? Is there any way to fix this? I am using the py-spidev library to communicate. I have had no problems communicating with this device via SPI using an Arduino Trinket Pro (3v3).

Below is a screenshot from my Saleae:

enter image description here

EDIT: 1: Add code

import spidev
import time

spi = spidev.SpiDev()
spi.mode = 1
spi.max_speed_hz = 500000

spi.open(0, 1)

def on():
    spi.xfer([0x03])
    time.sleep(9e-3)
    spi.xfer([0x00, 0x01])

def off():
    spi.xfer([0x03])
    time.sleep(9e-3)
    spi.xfer([0x01])

# Turn the device on and then off
on()
time.sleep(3)
off()
  • Hi, I do not understand. CS is channel 3? In the captured signal I cannot see anything strange wrt channel 3. – Ghanima Jun 1 '15 at 13:16
  • Yes. At around 65 us or so, the CS is going high, when it should remain low the entire transfer. – David Hagan Jun 1 '15 at 13:17
  • This is the part that I do not understand ;) What's the upper part of the diagram und what's the lower? The lower looks like "real measurement"... and does not show that glitch. – Ghanima Jun 1 '15 at 13:22
  • That's a great question. They are supposed to be the same..I will try and give Saleae a call to see if it's an issue with their firmware or something. I'm pretty sure it's an artifact though..because the data transfer does not always go through (sometimes it does, though!) – David Hagan Jun 1 '15 at 13:24
  • You might want to include a relevant snippet of code, if only to demonstrate there is nothing weird about it. – goldilocks Jun 1 '15 at 13:33

Your Answer

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

Browse other questions tagged or ask your own question.