Skip to content

add 2buffer transfer version #45

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

Merged
merged 5 commits into from
Oct 11, 2020
Merged

Conversation

jayzakk
Copy link
Collaborator

@jayzakk jayzakk commented Aug 17, 2020

PR as of trying to get Ethernet.h faster.
See notes to Ethernet.h at https://github.com/dbuezas/lgt8fx/wiki/Libraries-support
The library uses a (then existant) function, if SPI_HAS_TRANSFER_BUF is defined. If not, it does call transfer() for each byte.

As of Teeny source:

// SPI_HAS_TRANSFER_BUF - is defined to signify that this library supports
// a version of transfer which allows you to pass in both TX and RX buffer
// pointers, either of which could be NULL

Added this define, and added the function to do so.
The function is not fast enough to keep SCK running free at 16MHz SPI, but still faster than the one used before.
Reading+Writing with 2MByte/sec at 32MHz MCU doesn't seem possible ^^

At 8MHz SPI it makes SOME difference.

@jayzakk
Copy link
Collaborator Author

jayzakk commented Aug 17, 2020

I currently have some more optimizations, but sometimes the xfer stalls after some time.
For now, I GUESS it's the very long cables from SPI to W5500; 16MHz SPI is quite a lot.

IF it is just from the cables, I could get 10.7MBit/s (from 6.08 before) SEND and (after changing w5100.cpp to use this new function) 14.1MBit/s RECEIVE (from 8.2 before).

Will doublecheck/shorten the cables tomorrow.

@jayzakk
Copy link
Collaborator Author

jayzakk commented Aug 17, 2020

So, it was the cable. 12cm flexwire is too much for 16MHz. 6cm does...

I refactored to move the inlined segment to the class, it got too big for inlining a couple of times.
Additional PR (arduino-libraries/Ethernet#145) to use the transfer-double-buffer-SPI also on receive, not only on send.

Works like a charm. Updated performance data at the libraries page.

@dbuezas dbuezas force-pushed the master branch 2 times, most recently from 0dd93f9 to 26248ad Compare September 20, 2020 13:32
@dbuezas
Copy link
Owner

dbuezas commented Sep 20, 2020

Do you want to add an example in https://github.com/dbuezas/lgt8fx/tree/master/lgt8f/libraries/lgt328p/examples ? :)
I'm not sure if anybody will realise about the new method otherwise

@dbuezas
Copy link
Owner

dbuezas commented Oct 11, 2020

I just realised the function you added is standard in other boards, so it shouldn't need examples.
Merging now

@dbuezas dbuezas merged commit 06e386d into dbuezas:master Oct 11, 2020
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