Page 1 of 1

pyboard - SPI capture issue

Posted: Wed Jun 01, 2022 9:38 am
by roiz
Hi All,
I'm using pyboard connected to SPI lines. Those lines have messages that each message is 128Bytes.
when I'm using spi.recv(128) I'm getting a mess of messages ( some from the middle of a message some from the end of the message).

The SPI CLK is: 10Mhz

SPI space between messages is: 0.2mS

other properties:
pyb.freq() --> (168000000, 168000000, 42000000, 84000000)
SPI(2, mode=2, baudrate=25000000, polarity=0,phase=1,bits=8,firstbit=SPI.LSB)

Does someone have an idea how to capture the message as a complete message (when CS enables) and save it?

Thanks

Re: pyboard - SPI capture issue

Posted: Wed Jun 01, 2022 12:44 pm
by pythoncoder
I take it you're using peripheral (slave) mode, although mode=2 is not a value I'm familiar with. The Pyboard D I have here reports 0 and 260 for the two available values.

The problem is likely to be that your processing of the data takes longer than 200μs, causing the next read to be miss-framed. Bear in mind that .read() is a blocking call.

[EDIT]
I deleted your other post which is effectively a duplicate of this one.

Re: pyboard - SPI capture issue

Posted: Wed Jun 01, 2022 1:11 pm
by roiz
Thank you Peter for your help.

As you can see from the attached snapshot from Saleae that the frame(width of the message) is 98.4uS

Do you think that the pyboard can handle this kind of stream?

Do you think that other python modules can handle this kind of load?

Re: pyboard - SPI capture issue

Posted: Mon Jun 06, 2022 7:45 am
by pythoncoder
It's as I said above. You're getting 128*8=1024 bits at 10MHz so your frame period is indeed 98μs. It's the 200μs gap between these frames which may be the limiting factor, depending on what you do with those 128 bytes after you've received them.