SPI Maximum speed
SPI Maximum speed
Dear all
I want to drive shift registers using SPI as fast as possible.
Using the native SPI pin I should be able to push data at 80Mhz
But it seems like I can't go faster than 5Mhz ?
Also changing duty_cycles doesn't have any effect.
Can someone help me
thank you
Regards
Yves
I want to drive shift registers using SPI as fast as possible.
Using the native SPI pin I should be able to push data at 80Mhz
But it seems like I can't go faster than 5Mhz ?
Also changing duty_cycles doesn't have any effect.
Can someone help me
thank you
Regards
Yves
-
- Posts: 9711
- Joined: Thu Nov 26, 2015 4:08 am
Re: SPI Maximum speed
SPI is indeed perfectly capable of getting to 80MHz. It's pretty hard to find out why your implementation doesn't without knowing how exactly you set things up and measure speeds.
Re: SPI Maximum speed
My result:
in case use HSPI & VSPI mapped like this:
HSPI_CLK = 14 or 25 GPIO
HSPI_MOSI = 13 or 26 GPIO
HSPI_MISO = 12 or 32 GPIO
HSPI_CS = 15 or 33 GPIO
VSPI_CLK = 18 or 21 GPIO
VSPI_MOSI = 23 or 22 GPIO
VSPI_MISO = 19 or 19 GPIO
VSPI_CS = 05 or 23 GPIO
the maximum speed of CLK is 9 MHz. However, when I use VSPI at CLK = 26MHz - it work correctly.
I connected ESP32 + 2xMAX3421E and try blik led, whic connected to MAX3421E's GPIO
in case use HSPI & VSPI mapped like this:
HSPI_CLK = 14 or 25 GPIO
HSPI_MOSI = 13 or 26 GPIO
HSPI_MISO = 12 or 32 GPIO
HSPI_CS = 15 or 33 GPIO
VSPI_CLK = 18 or 21 GPIO
VSPI_MOSI = 23 or 22 GPIO
VSPI_MISO = 19 or 19 GPIO
VSPI_CS = 05 or 23 GPIO
the maximum speed of CLK is 9 MHz. However, when I use VSPI at CLK = 26MHz - it work correctly.
I connected ESP32 + 2xMAX3421E and try blik led, whic connected to MAX3421E's GPIO
Re: SPI Maximum speed
Well
CPU Frequency - 240MHz
Flash SPI speed - 80 MHz
At this moment - maximum stable frequensy of SPI = 18MHz.
(Send command and data to MAX3421E to blink led)
Perhups, the long wire don't allow setup SPI CLK more up
CPU Frequency - 240MHz
Flash SPI speed - 80 MHz
At this moment - maximum stable frequensy of SPI = 18MHz.
(Send command and data to MAX3421E to blink led)
Perhups, the long wire don't allow setup SPI CLK more up
- Vader_Mester
- Posts: 300
- Joined: Tue Dec 05, 2017 8:28 pm
- Location: Hungary
- Contact:
Re: SPI Maximum speed
You should thoroughly check how you set up your SPI.
It is in fact capable of 80MHz.
Although several notes: Do not use long wires in this case. Make them as short as possible.
At 80MHz long wires will distort the SPI clock a lot, and impedance.
So when you measure the SPI clock, measure it as close to the GPIO pin as possible.
It is in fact capable of 80MHz.
Although several notes: Do not use long wires in this case. Make them as short as possible.
At 80MHz long wires will distort the SPI clock a lot, and impedance.
So when you measure the SPI clock, measure it as close to the GPIO pin as possible.
Code: Select all
task_t coffeeTask()
{
while(atWork){
if(!xStreamBufferIsEmpty(mug)){
coffeeDrink(mug);
} else {
xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
}
}
vTaskDelete(NULL);
}
Re: SPI Maximum speed
I am having the same issue, but probably has to do with the CPU frequency. I can measure SPI at maximum 26 MHz. When I set it at 40, my scope doesn't show any signals. How can I change the CPU frequency higher? Is the function included in one of the examples?
- Vader_Mester
- Posts: 300
- Joined: Tue Dec 05, 2017 8:28 pm
- Location: Hungary
- Contact:
Re: SPI Maximum speed
SPI clock is independent of CPU clock. It is derived from APB_CLK which is the internal bus clock, and usually is 80MHz, and can not be adjusted.anakyr wrote:I am having the same issue, but probably has to do with the CPU frequency. I can measure SPI at maximum 26 MHz. When I set it at 40, my scope doesn't show any signals. How can I change the CPU frequency higher? Is the function included in one of the examples?
What board do you use? Does your board has a 26MHz crystal, or a 40MHz crystal?
Code: Select all
task_t coffeeTask()
{
while(atWork){
if(!xStreamBufferIsEmpty(mug)){
coffeeDrink(mug);
} else {
xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
}
}
vTaskDelete(NULL);
}
Re: SPI Maximum speed
I am using ESP-WROOM-32D module on the devkitc. I see that the module has a 40 MHz crystal.
Then how can I verify what you say about the internal bus clock? Where is that located? Isn't that derived from the CPU's clock as well?
Then how can I verify what you say about the internal bus clock? Where is that located? Isn't that derived from the CPU's clock as well?
- Vader_Mester
- Posts: 300
- Joined: Tue Dec 05, 2017 8:28 pm
- Location: Hungary
- Contact:
Re: SPI Maximum speed
Actually, I said a bit of bullsh*t above. The APB_CLK the SPI periferial is using is actually derived from the CPU clock.anakyr wrote:I am using ESP-WROOM-32D module on the devkitc. I see that the module has a 40 MHz crystal.
Then how can I verify what you say about the internal bus clock? Where is that located? Isn't that derived from the CPU's clock as well?
(Technical reference manual, top of page 40).
APB_CLK is 80MHz, and SPI max clock is APBfreq/2, so 40MHz, with all other deviders set to default state.
Are you 100% sure that you in fact have a 26MHz clock on the module?
By default in Menuconfig you select 40MHz clock, which tells the rest of IDF that you run a 40MHz CPU, which will use it in it's calculations as reference, even though you may be having a different clock!
By setting 40MHz, it means - i guess - that almost all the clock deivders are set to their default state - eg. no clock devision - so it should be 40MHz coming out. Having no devision and 26MHz coming out suggest to me that in fact you have a 26MHz crystal on your module.
Maybe I'm wrong, but it's woth trying to work with clock register settings. (TRM Page 132 SPI_CLOCK_REG)
You can also try to use the formula on Page 121, to calculate the register values needed for 26MHz clock, and then read out the registers, to see if register settings are the same as you calculated.
Code: Select all
task_t coffeeTask()
{
while(atWork){
if(!xStreamBufferIsEmpty(mug)){
coffeeDrink(mug);
} else {
xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
}
}
vTaskDelete(NULL);
}
Re: SPI Maximum speed
I'm 100% sure that I have a 40MHz crystal. Check attachment too. I will try first to include SPI_DEVICE_NO_DUMMY in order to ignore this checking, as the error message in red is saying. If it doesn't work, I will go to the registers
- Attachments
-
- Capture.JPG (97.02 KiB) Viewed 51602 times
Who is online
Users browsing this forum: No registered users and 66 guests