cancel
Showing results for 
Search instead for 
Did you mean: 

[STM32H7] How to use SDMMC with MDMA

MVerr.1
Associate

Hello Community,

I'm working on a storage module using SDcard for my project. In my application I would like to read and write to the SDcard using the MDMA as indicated in the reference manual of my micro-controller. For now I have the SDcard working in 4-bit mode but using the CPU.

I use the STM32H757II on a PCB connected to a SDcard reader on the same PCB.

With CubeMX I generated the code that allow me to mount a FATFS on my microcontroller and I can create/open/write/read on file with no problem.

But my application needs to log a lot of data to the sdcard periodically, to free-up the CPU I would like to do the transfer using a DMA.

In the reference manual 58.5.7 MDMA request generation it is explained that the MDMA can control the SDMMC peripheral to start new transfer

"The internal trigger lines from the SDMMC allow passing direct request to MDMA controller

to enable successive transfers from/to different internal RAM addresses without CPU use. [...]

The event can trigger the clearance of the DATAEND and CMDREND

flags and, eventually, a new transfer start, through MDMA direct access to the SDMMC

control and configuration registers, thus without CPU intervention."

However in CubeMX I don't seem to be able to link the SDMMC to the MDMA. I don't know either how to link an event of the SDMMC to trigger a change in configuration of those register with the MDMA.

How can I adapt what I have to use DMA instead of CPU.

How do you start a MDMA transfer to write on SDcard ?

Cheers,

Maurin

PS:

STM32CubeIDE Version: 1.3.0

STM32CubeMX Version: 5.6.0-RC6

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @MVerr.1​,

Thanks for your feedback and sorry for my late reply.

By my previous reply, I have tried to explain briefly the steps to configure SDMMC MDMA requests through STM32CubeMX GUI. Here is Application note to get started with STM32H7 Series SDMMC host controller with much more details and explanations.

You can also find multiple examples through Example Selector in STM32CubeMX developed to be a good start point for your project:

0693W000008wxapQAA.png 

Hope this helps you.

Khouloud.

View solution in original post

3 REPLIES 3

Hi @MVerr.1​ ,

Let me first welcome you to STM32 Community😊

If I well understand your question, you're asking about the STM32CubeMX feature in order to use MDMA requests to transfer data from/to SDMMC. Please correct me if I misunderstood.

To Configure SDMMC1 MDMA requests through CubeMX, firstly enable the SDMMC1 by selecting one of the available modes. Then select MDMA and Add Channel, a transfer request will be created by default, you can select one of the available MDMA events from the drop down list. You can add later the requests you needs for your project and configure them according to your requirements.

Hereafter a screenshot to clarify more the process:

0693W000008wSczQAE.jpg 

Hope this answers your question.

Khouloud.

MVerr.1
Associate

Hello Khouloud,

Thank you for the reply.

I would like to be able to on the SDcard using a DMA instead of the CORE_M7.

As I understood they are two solutions. One includes configuring the MDMA as you suggest and the other one is by using the IDMA of the SDMMC. What is the difference between the two solutions ? Also, after configuring everything like you mention, how can I start transfering data using the MDMA ?

Hi @MVerr.1​,

Thanks for your feedback and sorry for my late reply.

By my previous reply, I have tried to explain briefly the steps to configure SDMMC MDMA requests through STM32CubeMX GUI. Here is Application note to get started with STM32H7 Series SDMMC host controller with much more details and explanations.

You can also find multiple examples through Example Selector in STM32CubeMX developed to be a good start point for your project:

0693W000008wxapQAA.png 

Hope this helps you.

Khouloud.