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

Maximum SPI clock support #44

Open
min-hs opened this issue Aug 26, 2021 · 8 comments
Open

Maximum SPI clock support #44

min-hs opened this issue Aug 26, 2021 · 8 comments

Comments

@min-hs
Copy link
Contributor

min-hs commented Aug 26, 2021

Looking at the Pico SDK datasheet, SPI clock can be up to 100Mhz.
image

WIZnet5k_Lib uses 8Mhz, I want to operate at 30Mhz in Pico.
How to do this?

@anecdata
Copy link
Member

Looks like 8MHz is set here:

self._device = SPIDevice(spi_bus, cs, baudrate=8000000, polarity=0, phase=0)

@min-hs
Copy link
Contributor Author

min-hs commented Aug 26, 2021

I set the baudrate from 8Mhz to 30Mhz. But it works at the same speed.
Is there any other way to speed up?

@anecdata
Copy link
Member

How are you measuring the speed?

@min-hs
Copy link
Contributor Author

min-hs commented Aug 26, 2021

image
When it was set to 8Mhz, the speed was 49Khz.
image
The same speed came out at 49Khz when it was 30Mhz.
In the same way, the speed went down to 44Khz when it was 0.8Mhz.

Thank you.

@anecdata
Copy link
Member

anecdata commented Aug 26, 2021

In theory, the W5500 SPI max is 80 MHz. The Pico SPI max (as master) is 66.5MHz. But there are likely a variety of system constraints. For example, RAM is limited, so even if you get fast small bursts, it will be difficult to push much data through. On top of that, Python libraries and core C code handle several layers of the network stack and each will introduce their own performance constraints.

Do you have a link to the loopback test code?

@min-hs
Copy link
Contributor Author

min-hs commented Aug 26, 2021

@anecdata
Copy link
Member

What size packets is the client sending? I think you're just encountering system constraints. With overall ~50kHz using 8MHz SPI, it doesn't seem that SPI is the bottleneck. You could try instrumenting the sends and receives, vary the packet size, etc. You may find some combination that gives incremental improvement. But given 264kB of RAM, I think it would be difficult to take advantage of substantially higher speed - in an operational example, the data needs to be processed or saved to slower storage.

@min-hs
Copy link
Contributor Author

min-hs commented Aug 26, 2021

The Client sends 100kbytes of packet and returns to receive data.
I'd like to speed up using DMA, is there an example of SPI DMA in adafruit?

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

No branches or pull requests

2 participants