I’m new to Raspberry Pi and Python. I’m trying to write a byte to an SPI EEPROM (25LC512), but couldn’t get it to work. I’m pretty sure the connections are right. Somehow it always reads back 0xFF no matter what value I write. Can anyone take a look at my code and tell me what the problem is? Code, connection and logic analyzer captures are attached.
Datasheet is here. http://ww1.microchip.com/downloads/en/D ... 22065C.pdf
Code: Select all
#Writes/reads to & from 25LC512 #writes 0x33 to address 0x0001 and reads back import spidev import time spi=spidev.SpiDev() spi.open(0, 0) spi.max_speed_hz=7629 write_cmd=0x02 read_cmd=0x03 Hi_Addr=0x00 Lo_Addr=0x01 data0=0x33 dummy=0x00 write_sequence0=[write_cmd, Hi_Addr, Lo_Addr, data0] read_sequence0=[read_cmd, Hi_Addr, Lo_Addr, dummy] #write 0xF33 to address 0x0001 spi.writebytes(write_sequence0) time.sleep(0.005) #delay 5ms #read 1 byte from 0x0001 read_data=spi.xfer2(read_sequence0)