1

So I'm trying to write to as spi eeprom using the pigpio library, but I have the problem of only the clock line going active, none of the data or select lines.

I'm debugging the signals with the amazing piscope, from the same creator. I'm on a compute module 3, with the CMIO board, rev 3. I've verified I have the SPI driver loaded (/dev/spidev0.0), and I'm on the latest raspbian.

My physical connections are as follows (along with all necessary ties to vcc/gnd on the eeprom pins):

EEPROM CS  <--> CM GPIO_8
EEPROM SO  <--> CM GPIO_9
EEPROM SI  <--> CM GPIO_10
EEPROM CLK <--> CM GPIO_11

I also have the official 7" display working and attached using i2c on GPIO 0 and 1, and connected to the DSI 1 peripheral, along with a working serial console on GPIO 14 + 15.

I'm getting a clock that matches my data I'm writing, but I see zero data actually being transmitted, as well as no active low on either of the slave select pins. See piscope reading:

SPI Write with PIGPIO

Here's my rather simple python test program:

#!/usr/bin/python

import pigpio
import time
import sys

pi = pigpio.pi()
if not pi.connected:
    print("pigpio fail on open")
    exit(0)

eeprom = pi.spi_open(0, 32000, 0) # open spi0.0 @ 32k

print("eeprom: " + str(eeprom))

pi.spi_write(0, b'\x06') # write latch enable

time.sleep(0.001) # allow CE to toggle

pi.spi_write(0, b'\x02')         # actual write command
pi.spi_write(0, b'\x00\x00\x00') # address
pi.spi_write(0, b'\xCC')         # easily identifiable data

pi.spi_close(eeprom)
pi.stop()

Thanks for the help. Any idead/thoughts/questions would be greatly appreciated.

4
  • The first parameter to each of the spi_write calls is the handle, in your case eeprom not 0. Misleading examples on my part. I would make that change to your code even though it doesn't seem to explain what you are seeing. E.g. spi_write(eeprom, b'\x06').
    – joan
    Jan 18, 2018 at 0:02
  • 1
    pigpio has its own SPI driver, it talks to the SPI hardware directly, so the Linux driver /dev/spidev0.0 is not actually used.
    – joan
    Jan 18, 2018 at 1:07
  • Oh I see. Should I unload spi_bcm2835 from the kernel then?
    – user79543
    Jan 18, 2018 at 1:20
  • 1
    No need, but as pigpio drives the hardware directly (affecting the hardware registers) it may be incompatible with using the Linux driver at the same time on the same device. pigpio sets the settings at each invocation, the Linux driver probably doesn't so I'd try not to use both at the same time.
    – joan
    Jan 18, 2018 at 2:08

1 Answer 1

2

Turns out there was nothing wrong, other than a bad solder job. It was a bridged pin on the eeprom breakout board. Disconnected, the bus runs perfectly fine.

Your Answer

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