测试SPI

测试SPI

SPI3:MOSI与MISO(即B4/B5)短接。如果从MISO返回的数值(b'0123456789')等于MOSI的输出,则工作正常。

from pyb import SPI
buf = bytearray(10)
spi = SPI(3, SPI.MASTER, baudrate=9600000, polarity=1, phase=0, crc=0x07)
data = spi.send_recv(b'0123456789')
spi.send_recv(b'0123456789', buf)
#spi.send_recv(buf, buf)

print(repr(buf))

输出结果:未短接MOSI和MISO引脚时

>>>
PYB: sync filesystems
PYB: soft reboot
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff')

输出结果:短接MOSI和MISO引脚时

bytearray(b'0123456789')
bytearray(b'0123456789')

 

posted on 2020-03-20 10:38  iBoundary  阅读(520)  评论(0编辑  收藏  举报

导航