When I run SPI at 1Mhz things seem to be better (the issue is less pronounced but still present), however any speed above this (2MHz) and up I start encountering data transmission errors. The issues worsen with speed, at 80Mhz the SS line oscillates so bad it looks like the clock line.
Here's a shot from my oscilloscope with 80MHz SPI (yellow = SCK, cyan = SS). The ESP32 board is not on a breadboard, it's only hooked up to my scope, nothing else is attached.
Link to screenshot just in case the image embed doesn't work https://imgur.com/a/ZzvEAb6
This is the code I'm using to send data. On the other side I have an STM32 slave that echos back received data (for testing purposes):
Code: Select all
from machine import Pin, SPI, freq
vspi = SPI(2, baudrate=1000000, polarity=0, phase=0, bits=16, firstbit=0, sck=Pin(18), mosi=Pin(23), miso=Pin(19))
hspi = SPI(1, 10000000, sck=Pin(14), mosi=Pin(13), miso=Pin(12))
ss = Pin(25, Pin.OUT, value=1)
def spi_send(send_bytes, channel='vspi'):
send_bytes = send_bytes + b'\x00\x00'
rec_buf = bytearray(len(send_bytes))
ss.value(0)
eval(channel).write_readinto(send_bytes, rec_buf)
ss.value(1)
return rec_buf if rec_buf[2:] == bytearray(send_bytes[:-2]) else ("ERROR", bytearray(send_bytes), rec_buf)
Code: Select all
spi_send(b'test')
Your feedback or insights would be appreciated! Thanks for the help.