to test the SPI Bus, I connectet the X and Y pins.
X8 MOSI -> Y8 MOSI
X7 MISO -> Y7 MISO
X6 SCK -> Y6 SCK
With my code I want send wit SPI X a message to SPI Y and print it.
But I get an OSERROR 116. Why? Where is my mistake?
What must I do with the Slave Select (SS)?
When I connect MISO mit MOSI bei SPI X, I can send and recive a message.
Code: Select all
# main.py -- put your code here!
import pyb
print ('INIT des Schalters')
switch = pyb.Switch()
spi = pyb.SPI(1, pyb.SPI.MASTER, baudrate=600000, polarity=1, phase=0, crc=0x7)
spi2 = pyb.SPI(2, pyb.SPI.SLAVE, baudrate=600000, polarity=1, phase=0, crc=0x7)
buf = bytearray(4)
buf2 = bytearray(4)
print('send 1234 ')
spi.send(b'1234')
#print('buf',buf)
print(' empfange in buf')
print('buf',spi2.recv(4))
#print('send 1357 und empfange in buf')
#spi.send_recv(b'1357',buf)
#print('buf',buf)
Thank you for your help.