cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_SPI_Transmit & HAL_SPI_Receive timing issue

sai_sankar_rao_R
Associate II

Hi all,

I am currently working with the STEVAL-PROTEUS1 Board, which incorporates the STM32WB5MMG module and the IIS3DWB high-bandwidth accelerometer sensor, interfaced via SPI_1.

According to the IIS3DWB sensor datasheet, it supports a clock frequency of up to 10MHz and an Output Data Rate (ODR) of 26667Hz (37 microseconds).

My objective is to collect sensor data at an ODR of 26667Hz.

Here are the steps I have taken so far:

  1. Configured SPI_1 to 8MHz.
  2. Configured the sensor to generate an ODR interrupt, which is successfully triggering every 37 microseconds.

The issue arises when collecting data (6 bytes) from the sensor, which is taking 42 microseconds. Ideally, this should not exceed 10 microseconds using HAL functions in blocking mode. I have also tried using non-blocking mode (DMA), but it is taking the same or more time.

Could anyone help me understand if the HAL function is supposed to take 42 microseconds, or if there might be an issue with my implementation?

Note: The M4 core is running at 64MHz and the M0 core at 32MHz.

Thank you in advance for your assistance!

1 REPLY 1
TDK
Guru

42 microseconds for a blocking HAL call seems reasonable to expect. If you need faster speed, might have to write your own SPI handling. You can also change to the Release build configuration to gain some speed.

Interrupts at more than about 10 kHz start to become more difficult.

Using circular DMA with HAL, and disabling the half-complete interrupt, is probably going to give you the best speed.

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