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 working on the STEVAL-PROTEUS1 Board, which features the STM32WB5MMG module and the IIS3DWB high bandwidth accelerometer sensor interfaced via SPI_1.

According to the IIS3DWB sensor datasheet, it supports up to 10MHz (CLK) and an ODR of 26667Hz (37 microseconds).

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

Here are the steps I've 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.
  3. 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.

Could anyone help me understand if the HAL function is supposed to take 42 microseconds, or if I might be doing something wrong?

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

Thanks in advance!

3 REPLIES 3
gbm
Lead III

Use DMA for SPI - "fire and forget" is much more efficient than interrupt-driven SPI.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

Thank you for your suggestion. I will implement this solution and see if it helps resolve my timing issue. However, I would also like to understand the underlying cause of the problem.

sai_sankar_rao_R
Associate II

Hi @gbm ,

         I attempted to resolve my timing issue using DMA, but it seems to be taking more time compared to the polling method. I’m not sure why this is happening. Could you please assist me with this?

For your reference, I have attached the code as a zip file.

Thank you.