cancel
Showing results for 
Search instead for 
Did you mean: 

How to use HAL_SPI_Receive_DMA with dma1 and SPI6 ?

ALE C.1
Associate II

Hi,

I am currently working on the STM32H743 and i'm trying to bring data from SPI6 to a buffer in D2. As I have a lot of data to read i would like to use the DMA in order to transfer data without using the cpu. I don't understand whether I can use the DMA1/2 in order to do this or not.

For instance, with the SPI1, in D2, I can choose the DMA request as the DMA_REQUEST_SPI1_RX/TX. However the only request I can use with SPI6 is BDMA_REQUEST_SPI6_RX/TX. does it mean that I can only use the bdma here ?

However as BDMA is restricted to the D3 domain, it can't write data on a buffer in D2. How can I write it then ?

Do someone have a clear answer to this ? if so could you explain the required step i would need to implement the solution.

14 REPLIES 14

> However the only request I can use with SPI6 is BDMA_REQUEST_SPI6_RX/TX. does it mean that I can only use the bdma here ?

Yes, because SPI6 itself is in D3, too. DMA requests tend not to cross clock domains.

> However as BDMA is restricted to the D3 domain, it can't write data on a buffer in D2. How can I write it then ?

You simply can't, that's the constraint of the hardware.

Use a different SPI if SRAM4 does not fit your needs.

JW

MHana.1
Associate III

Hello,

I'm using the same microcontroller migrating from STM32F7 to STM32H743, so we are forced to use same pinout and peripherals. My issue is that when trying to use BDMA to send and receive using SPI6 it is not working although SPI6 alone is working perfectly. I tried to generate STM32CubeMx example and tried to modify it but it is not working. I'm using SPI6 with BDMA channel0 for Tx and channel1 for receiving. Also used DMAMUX2_Channel0 and DMAMUX2_Channel1 to handle DMA_SPI6_TX_REQUEST_ID and DMA_SPI6_RX_REQUEST_ID. I enabled BDMA, SPI6, GPIOG clocks and BDMA, SRAM4 in D3 domain. Is there any thing I missed or any working example on SPI6 and BDMA to use.

Thanks and regards.

Be more specific with "not working".

Are the buffers in SRAM4?

Read out and check/post content of relevant SPI, DMA, DMAMUX and GPIO registers.

JW

MHana.1
Associate III

Thanks for your response.

I started to modify the example I generated by STM32CubeMX and started to send SPI using DMA but it takes about 30 mSec to send. I'm trying to solve this issue and will check my code. I'm thankful if there any advise from you.

MHana.1
Associate III

Yes the buffers are in SRAM4.

> it takes about 30 mSec to send

And why is this unexpected? What is the baudrate? Have you observed the SPI signals using oscilloscope/LA?

JW

MHana.1
Associate III

Dears,

the delay was due to another waiting in code as it is a legacy code. The BDMA is sending and receiving perfectly. my missed point was the needed actions on SPI when sending with BDMA so I used the generated example after modifications as reference. Thanks for your help.

Hello MHana.1,

which is the example code that you considered? I have the same situation, in fact I'm using SPI6 with BDMA channel0 for Tx and channel1 for receiving. I don't understand how set DMAMUX2_Channel0 and DMAMUX2_Channel1 to handle DMA_SPI6_TX_REQUEST_ID and DMA_SPI6_RX_REQUEST_ID.

Have u any problems to share your code, in which I can get ideas?

Thanks and regards.

MHana.1
Associate III

Hello GCava.2,

Attached my test code.