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

SPI > 33Mhz possible #5

Open
3s1d opened this issue Jan 14, 2023 · 2 comments
Open

SPI > 33Mhz possible #5

3s1d opened this issue Jan 14, 2023 · 2 comments

Comments

@3s1d
Copy link

3s1d commented Jan 14, 2023

Hi,

I just wanted to let you know that I have the communication working using the spi hardware (+dma) of the rp2040. Actually you provided the trick:

	aspAcquire(aps);

	/* inititate read */
	uint8_t cmd[5] = { APS_FASTREAD };
	cmd[1] = addr >> 16;
	cmd[2] = addr >> 8;
	cmd[3] = addr & 0xFF;
	cmd[4] = 0;				//dummy
	spi_transfer(aps->spi, cmd, NULL, sizeof(cmd));

	/* receive data */
	//note: for fastread (>33Mhz) we need to switch to sampling on the falling egde
	if(aps->spi->baud_rate > 33000000)
		spi_set_format(aps->spi->hw_inst, 8, SPI_CPOL_0, SPI_CPHA_1, SPI_MSB_FIRST);
	spi_transfer(aps->spi, NULL, buf, size);
	if(aps->spi->baud_rate > 33000000)
		spi_set_format(aps->spi->hw_inst, 8, SPI_CPOL_0, SPI_CPHA_0, SPI_MSB_FIRST);

	aspRelease(aps);

Prior to the read operation I reconfigure the spi hardware to do sampling on the falling edge.
I have it tested at 62.5Mhz (maximum for a pico running at default speed (125Mhz)).

Cheers,
Juergen

@polpo
Copy link
Owner

polpo commented Jan 14, 2023

Thank you for opening this issue, that is great to hear! I will try out this code. To get 62.5MHz, do you have to reconfigure the peripheral clock? When trying to use the SPI hardware I came across this post: https://forums.raspberrypi.com/viewtopic.php?t=333214. I typically overclock the Pico (in the 266-280MHz range) and wonder if the baud rate will also scale as I overclock.

@3s1d
Copy link
Author

3s1d commented Jan 16, 2023

Hi Polpo,

no have not done anything like that. My pico should run at stock 125Mhz. I can confirm that the SPI clk runs at 62.5Mhz. I measured it with my scope.

Bests,
Juergen

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