I am communicating through SPI an adc with integrated SPI with a lopy. My problem is that I receive the correct data most of the time but not all the time, so I used a logical analyzer to see the data frame sent by the lopy, and when I saw it I realized that sometimes the clock gets out of control. Is there any way to make sure that this doesn't happen?
from machine import SPI
spi = SPI(0, mode=SPI.MASTER, baudrate=4000000, polarity=0, phase=1, firstbit=SPI.MSB)
rbuf = bytearray(4)
spi.write_readinto(bytes([0xD5, 0x8B, 0xD5, 0x8B]), rbuf)
Images of the logic analyzer (three data frames):
The data frame above is the clock and the bottom one is the MOSI. As you can see in the third image, the clock isn't correct in the second and third byte.
Thank you and sorry about my english.