cancel
Showing results for 
Search instead for 
Did you mean: 

DMA SPI need 2 read S2LP Module

Quentin_27
Associate III

Hi everyone,
I'm currently working on project witch use SPi with DMA and S2LP Module

I have a function that initializes the DMA portion :
image_2025-10-20_110824548.png

In my code I try to read information in DMA through the SpiritDeviceVersion and SpiritReadnbinfifo functions:

image_2025-10-20_105908658.png

 

 

However, I get my data, but only when I call a DMA read 2 times :

nbOctetRecuB = the value I should read from nbOctetRecuA (0xC1)

nbOctetRecuB2 = the value I should read from nbOctetRecuB (0x0A, my FIFO element count)

nbOctetRecuC = the value I should read from nbOctetRecuB2 (0x0A, my FIFO element count) => whereas I expect 0xC1.

 

Below are one of those function:

image_2025-10-20_110759326.png

I don't understand witch element is missing, why i need to perform another DMA operation to get my data ?

Just a heads-up, a double DMA operation is needed : so if I read S2LP register with DMA, and after Reread DMA without using SPI (ex no CS command) i get my data, this is what it tell me the problem isen't from the SPI ?

Is anyone get tis issue ?

Tanks for your time, Regards.

3 REPLIES 3
mƎALLEm
ST Employee

Hello @Quentin_27 ,

Please use </> button to share your code instead of pasting screenshots. Please read How to insert source code.

Thank you for your understanding.

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.
Andrew Neil
Super User

Does it work OK without DMA ?

Have you used an oscilloscope or logic analyser to see what's actually happening on the SPI wires?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
Quentin_27
Associate III

Hi,

Yes it works without DMA,

All is correct on SPI Wires as you can see below  (Last ligne is CS#, Frequency 1MHz, and I have try 4MHz):
image_2025-10-20_133518917.png

Tanks for your time, Regards.