Skip to main content
KKIM.6
Senior
February 1, 2025
Question

SPI setting speed is too low.

  • February 1, 2025
  • 1 reply
  • 3650 views

Hi, I'm testing a custom STM32WB09TEF7TR board.

 

To communicate with the analog front end, I need to use SPI.

However, SPI communication requires 17 us setting time, which means around 60 kHz.

This speed is very slow.

So, the Initiation of SPI becomes the bottleneck of the speed of the overall system.

 

So, I wonder if there is anything I missed.

Below is the oscilloscope result for the SCLK (yellow) MOSI (green) and MISO (blue) CS (pink) pins, respectively.

After the CS pin reset, around 17 us are required to start SPI transmission.

scope_1.png

 

 My code for this function is below.

 

void spi_read_write(void)

{

GPIOA->BSRR = GPIO_BSRR_BR9; // Reset CS_pin

HAL_SPI_TransmitReceive_DMA(&hspi3, SPI_tx_DMA, SPI_rx_DMA, 5);

HAL_Delay(1);

GPIOA->BSRR = GPIO_BSRR_BS9; // Set CS_pin

}

 

 

1 reply

TDK
Super User
February 1, 2025

HAL takes a bit to get started. To speed it up, you can switch to the Release configuration at the expense of some debugging functionality. You can also increase the chip clock speed. Otherwise you will need to write your own driver.

 

There are a variety of ways to get fast communication between devices. Consider circular DMA triggered by a timer.

"If you feel a post has answered your question, please click ""Accept as Solution""."
KKIM.6
KKIM.6Author
Senior
February 1, 2025

@TDK wrote:

There are a variety of ways to get fast communication between devices. Consider circular DMA triggered by a timer.


Do you mean that we can put multiple SPI requests before the previous SPI communication ends using a timer interrupt?

TDK
Super User
February 1, 2025

It's probably best to focus on the functionality you want rather than listing all the possibilities.

"If you feel a post has answered your question, please click ""Accept as Solution""."