-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blocking SPI slower than it needs to be? #180
Comments
I've just looked at the implementation of the |
That's how SPI works in general. There might be room for a specialised uni-directional communication but that would probably not something that just works in a generic way. |
I was expected the blocking write buffer method to be able to fully utilize the SPI bandwidth, but in practice I am seeing ~3us idle between bytes written. I guess DMA is the solution for this... |
Yea, I don't think you'll be able to completely avoid delays without DMA. |
DMA will be fastest of course, but there seems to be some value in improving the blocking With a 32Mhz sysclk, and 16Mhz spi speed, this proposed change: improves performance from ~3.7us per byte to ~1.2us per byte. |
Looks good to me. But I can't test it at the moment. |
Fixed in #181 |
I'm trying to understand why my SPI LCD display updates are slower than I would expect. I'm using a blue pill board, and driving the display with this library:
https://github.com/yuri91/ili9341-rs
The ili9341-rs library relies on the blocking SPI implementation. I've just noticed that this stm32f1xx-hal crate relies on the default implementation of the blocking Write trait:
https://github.com/stm32-rs/stm32f1xx-hal/blob/master/src/spi.rs#L321
and this default implementation wait for received bytes, despite discarding them:
https://docs.rs/embedded-hal/0.2.3/src/embedded_hal/blocking/spi.rs.html#72
Is this actually necessary with the stmf1xx processors? Would a hand written Write trait without the blocking read work correctly and return faster?
The text was updated successfully, but these errors were encountered: