Skip to main content
ASmit.4
Associate II
April 16, 2020
Question

How do I get 32Mbps SPI?

  • April 16, 2020
  • 3 replies
  • 2259 views

I’m using the nucleo board, and I’ve got SPI working correctly (mostly) with default settings using CubeIDE. However, the data sheets stated that SPI can run at 32 Mbps, and I’m only getting half that rate.

The SPI Prescaler is set to the minimum value of /2, so I’m guessing I need to change my clock configurations to get up to the max rate?

What do I need to do to get the max SPI rate; because I’m not getting with default settings?

This topic has been closed for replies.

3 replies

Remi QUINTIN
Technical Moderator
April 16, 2020

What is the source of your system clock?

Could you send a picture of your clock system configuration from CubeMX?

ASmit.4
ASmit.4Author
Associate II
April 16, 2020

HSE_SYS is the current source of my system clock. I’ve cross posted this question, which includes a pictute of the clock configuration, here:

https://www.reddit.com/r/embedded/comments/g2gigh/how_to_configure_stm32wb_for_maximum_spi_data_rate/?utm_source=share&utm_medium=ios_app&utm_name=iossmf

Tesla DeLorean
Guru
April 16, 2020

You'd need to be running AHB/APB clocks at 64 MHz

Probably want to be using DMA, although not sure where you're going to sink that amount of data

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
ASmit.4
ASmit.4Author
Associate II
April 16, 2020

OK, I've changed my System Clock Mux to PLLCLK, and now my SPI Clock is where I expect it to be. However, I see that my interval between transmitted bytes is 11us. How can I shorten that timing? 0693W000000Vy3vQAC.png

waclawek.jan
Super User
April 16, 2020

> HAL_SPI_Transmit

Write your own. Maybe you'll find the explanation for the delays between the frames.

JW

ASmit.4
ASmit.4Author
Associate II
April 17, 2020

Just a quick follow up here. I checked the timings on the HAL_SPI_Transmit() function, and it appears most of the overhead comes from the HAL function pre and post checking. There's at least 2us burned from the time you enter the function until the first bit is transmitted. I'm going to try a Low Layer SPI implementation and see what that improves.

Senior III
April 17, 2020

Once you have your own low level implementation of the SPI routines, try to use DMA, as @Community member​ suggested.

Maybe there are also HAL with DMA routines ?