Open BryceBeagle opened 1 year ago
I've encountered the same issue while driving WS2812B using SPI. No matter what I did, I couldn't get the lights to work properly.
After using an oscilloscope, I found that spi.write
will cause SCK stops for a period of time after each byte is sent.
I was able to work around the issue by using DMA transfers instead.
If I try to
.write
more than a certain number of bytes[1] (exactly) in a single call/packet, theSCK
signal stops working properly, hiccuping at regular intervals and preventing the data from getting sent. A couple other users on the Embedded Rust matrix server reported having similar issues and it was requested that I open an issue for this.I am using an
stm32f103
bluepill. I have tried with both thev0.9.0
release of the HAL and the head of master (f063d5bef at time of writing).[1]: With
opt-level = 2
this is >13 bytes; withopt-level = 3
this is >28 bytes. These numbers are exact and deterministic13 bytes of![Screenshot from 2022-09-08 21-51-58](https://user-images.githubusercontent.com/5437880/189462276-8ac83fc6-a7d1-43f2-9d5b-1511f6cf83ca.png)
0b10101010
atopt-level = 2
:14 bytes of![Screenshot from 2022-09-08 21-53-07](https://user-images.githubusercontent.com/5437880/189462267-c270f4ab-4ea2-443a-9823-606605fca9f6.png)
0b10101010
atopt-level = 2
:Reproducible snippet: