Skip to content
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

ESP32 Family: Add multiple transctions to SPI for improved efficency #7686

Merged
merged 3 commits into from
Mar 9, 2023

Conversation

gamblor21
Copy link
Member

While doing some other work with my Saleae, I noticed large SPI transfers had a gap every 4Kb for about 300 microseconds. Over larger transfers this delay adds up and becomes more apparent the faster the SPI frequency as the delay is constant vs frequency.

This PR adds multiple transaction queuing. The current implementation sends 1 transaction at a time. In the linked IDF example it shows how to include multiple transactions. This basically eliminates the delay (it drops to 14 microseconds).

The only downside I have found is you go from one SPI transaction in memory to 10, each transaction is 34 bytes so not a large increase.

For example:
At 80Mhz for a 100 KB transfer the ideal transfer time is 10 milliseconds. The current 300 microsecond delay every 4KB results in a total delay of ~7.2 milliseconds resulting in a total time of 17.2 milliseconds. Almost double the expected time.
At 10Mhz for a 100KB transfer the ideal transfer time is 80 milliseconds. The added 7.2 milliseconds delay for 100KB results in 87.2 milliseconds, almost 10% more then expected.

The most obvious example of the speedup having a positive effect will be in SPI graphic displays (including displayio), But any large SPI transfer will see a speedup, and the faster the frequency the more apparent.

The current transaction buffer size of 10 was arbitrarily chosen.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you!

@tannewt tannewt merged commit fcc4299 into adafruit:main Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants