One pyboard acts as a Slave, the other one as a master
The problem is, the communication works for some short period of time and then something breaks and the comms go nuts.
Master code:
`py2=pyb.SPI(2, pyb.SPI.MASTER, 500000, polarity=0, phase=1, bits=8, firstbit=pyb.SPI.MSB, ti=False, crc=0x7)
ss=pyb.Pin('Y5', pyb.Pin.OUT_PP)
ss.high()
def py2py():
ss.low()
pyb.delay(5)
data=py2.send_recv(b'\x00\xaa\x00\xbb\x00\xaa\x00\xbb\x00\xaa\x00\xbb\x00\xaa\x00\xbb\x00\xaa\x00\xbb\x00\xaa\x00\xbb')
ss.high()
`
Slave code:
`py1 = pyb.SPI(2, pyb.SPI.SLAVE, 500000, polarity=0, phase=1, bits=8, firstbit=pyb.SPI.MSB, ti=False, crc=0x7)
data=bytearray(24)
ss=pyb.Pin('Y5', pyb.Pin.IN)
def f(a):
py1.send_recv(data)
inter=pyb.ExtInt(ss, pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_DOWN, f)
`
As you can see, the Slave pyboard uses an interrupt. So, when Master calls the function py2py(), he triggers the interrupt on the Slave who then does what it does, it sends the data.
And it works for some short period of time, then it just breaks and the Master starts receiving weird buffers. Or, if I also have comms via i2c(1) on Master, the SPI comm completely breaks and Master never receives anything --> data is data=b'\x00'*24
I'm not profesionallist for communications and it's still a new thing for me, so if somebody can help me, please do
What I did try is using only py2.recv and py1.send, got the same thing. And, it doesn't work without the pyb.delay() in py2py() func.
Note, the pyboards both have other comms via i2c and the other SPI pins (all the comms work perfect), but they do not use interrupts. The only interrupt that is used in the whole programs is the one that is written here.
And I know that the SPI comms, when pyboard acts as Master, works completely fine. It has been tested on one of my sensors and it works all the time as it should
Help me please