Closed danilinao closed 11 months ago
Thanks for reporting! Can you please share the link to the relevant project on Wokwi?
Just updating that I managed to reproduce the issue, but still haven't had a chance to dig into it. It's on my radar, though.
reporting here beacuse it seems related:
I tried to run some micropython SPI code on the emulator, and found out that spi.write fails to write any any buffer of length longer than 32 (included). no data ever reaches the rp2040js's spi data callback, not even the first 32 bytes.
e.g given the firmware:
from machine import SPI
spi = SPI(0)
spi.write(b"0123456789abcdef0123456789abcde")
spi.write(b"0123456789abcdef0123456789abcdef")
the rp2040js spi callback will only be called for every byte in the first write.
investigating the micropython repo, I figured ports/rp2/machine_spi.c#machine_spi_transfer is the function responsible for actually calling the pico sdk spi_write_blocking func. Look at its code: if the input buffer length is >= 32, then data is sent to SPI via DMA (a valid optimization) which in rp2040js is not yet implement
good news are DMA already exists in rp2040js, it just doesn't seem wired into the SPI peripherial. Im looking into the fix 🙏
Fixed!
Thanks @guysv for figuring this out
When i'm try run this code:
the emulator freezes and the following messages appear in the js console