cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic SPI communication using STM32U5

DK3
Associate II

Hi

I use STM32U575I-EV.

I want to periodically read data from an external SPI device without CPU.

The SPI device will emit a data ready signal(active low gpio), so I want to use that as a trigger to read the data.

Ideally, I would like to perform multiple SPI receptions while keeping the CPU in Stop mode.

To read data from a SPI device, just do something like HAL_SPI_Receive_DMA().

 

Are there any good example projects ?

Or how can I do this ?

I read this articles, but it didn't solve my problem.

Solved: STM32U5 SPI Continuous Communication - STMicroelectronics Community

Best regards.

2 REPLIES 2
Amel NASRI
ST Employee

Hi @DK3 ,

I believe that the LPBAM is the good solution for your case.

To know more about the LPBAM, please refer to the wiki article Getting started with LPBAM.

As stated there, a typical example is provided in STM32Cube\Repository\STM32Cube_FW_U5\Projects\NUCLEO-U575ZI-Q\Applications\LPBAM\LPBAM_SPI_TransmitReceive. You can check the readme file to understand more the example.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

DK3
Associate II

Hi, @Amel NASRI 

Thanks to your advices, I was able to do SPI read automatically.

I want to generate a DMA interrupt once every two times and use the receive buffer continuously.

(e.g. Receive1 uses RxBuff[0] ~ RxBuff[7], Receive2 uses RxBuff[8] ~ RxBuff[15])

So, I created two SPI_Receives as shown in the attached image and configured "Transfer Event Generation" as follows.

Receive1 : Transfer Event Generation = TC and HT generated on the last linked-list item

Receive2 : Transfer Event Generation = TC and HT generated on each block

DK3_0-1723540839321.png

This worked as intended. 

Is this setting correct ? Is there a better way ?

When I set Transfer Event Generation of Receive1 and Receive2 to TC and HT generated on the last linked-list item, DMA interrupt was not generated.

The latter setting seemed like the correct setting, but it didn't work.

Please tell me that reason.

Best regards.