Hallo erstmal,
ich versuche aktuell das EEPROM 25LC040 zum Laufen zu bringen allerdings wird mir beim lesen immer unterschiedliche werte zurückgegeben.
Code
import RPi.GPIO as GPIO
import time
mosi = 19
miso = 21
clk = 23 #clock
cs = 26 #chipselect
GPIO.setup(mosi, GPIO.OUT)
GPIO.setup(miso, GPIO.IN)
GPIO.setup(clk, GPIO.OUT)
GPIO.setup(cs, GPIO.OUT)
GPIO.output(cs, GPIO.HIGH)
GPIO.output(clk, GPIO.LOW)
GPIO.output(mosi, GPIO.LOW)
def sendValue(value):
for i in range(8):
if(value & 0x80):
GPIO.output(mosi, GPIO.HIGH)
else:
GPIO.output(mosi, GPIO.LOW)
GPIO.output(clk, GPIO.HIGH)
GPIO.output(clk, GPIO.LOW)
value <<= 1
def readValue():
wert = 0
for i in range(7, -1, -1):
GPIO.output(clk, GPIO.HIGH)
if(GPIO.input(miso)):
wert += 2**i
GPIO.output(clk, GPIO.LOW)
return wert
def sendData(addr, data):
GPIO.output(cs, GPIO.LOW)
if(addr>>8):
sendValue(10)
else:
sendValue(2)
sendValue(addr & 0xFF)
sendValue(data)
GPIO.output(cs, GPIO.HIGH)
def readData(addr):
GPIO.output(cs, GPIO.LOW)
if(addr>>8):
sendValue(11)
else:
sendValue(3)
sendValue(addr & 0xFF)
wert = readValue()
GPIO.output(cs, GPIO.HIGH)
return wert
#ZU TESTZWECKEN
sendData(1, 10)
time.sleep(0.5)
print(readData(1))
Display More
ausgegeben werden allerdings immer unterschiedliche Werte...
Großer Dank schonmal für die Hilfe
RasPiNeuling