Skip to main content
AWilk
Associate
Oct 9, 2019 9:30 AM UTC
Question

SDCard SDIO 4Bit with DMA using FatFs Q1: How to check if DMA is working? Q1: How to check if 4Bit Mode is set correctly?

Hi Community,

I use a STM32F405 to access a uSDCard.

Software: CubeMX V5.3 and SW4STM32 (Eclipse Neon.3 Release (4.6.3))

The good news, I can communicate with the SDCard (create files, write content and delete files. So far so good, but now the questions:

Q1: How to check if DMA is working?

Where can I see/check that I actually use the DMA which is added in CubeMX in the SDIO section?

0690X000009kCu9QAE.png

Because if I remove the two DMA lines for RX and TX and press the "GENERATE CODE" button again, after re-compiling my unchanged user-code is still working perfectly. I thought there should be a problem now...

Of course I checked the www for information and I found a tutorial on youtube (https://www.youtube.com/watch?v=0NbBem8U80Y) where the guy changes the content of the library functions BSP_SD_ReadBlocks_DMA() and BSP_SD_WriteBlocks_DMA() from bsp_driver_sd.c and he changes the content of SD_read() and SD_write() from sd_diskio.c to use the DMA.

Are these steps still necessary? (I haven`t changed my code so far!)

Regarding this steps I thought that the BSP_SD_ReadBlocks_DMA() and BSP_SD_WriteBlocks_DMA functions should be used somewhere in the f_write() or f_read() functions (out of the Middleware ff.c) that I use in my user-code too.

When I get through all the library-code of e.g. f_write() I couldn`t find one "DMA" function. That is why I`m wondering if I use the DMA after the code-changes at all.

Hopefully someone could explain the connection of f_write with "DMA" functions or ff.c with sd_diskio.c to me. I don`t get it unfortunately...

Q2: How to check if 4Bit Mode is set correctly?

After generating the library functions with CubeMX I found the first hint in the MX_SDIO_SD_Init() function:

hsd.Init.BusWide = SDIO_BUS_WIDE_1B;

I think this sets the bus to 1B for the very first initialize/communication?

After calling the BSP_SD_Init() to initialize my SDCard I see in the library-code that a wide operation is enabled.

   /* Enable wide operation */

   if (HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B) != HAL_OK)

   {

     sd_state = MSD_ERROR;

   }

Is this the final step to set the 4Bit SDIO data transfer or do I need something else?

I hope I could describe my issues in a proper way.

I`m looking for your answers.

All the best

Alexander

This topic has been closed for replies.

4 replies

AWilk
AWilkAuthor
Associate
Oct 21, 2019 11:54 AM UTC

To whom it may concern:

regarding Q2:

Thanks to an oscillocope I can tell you "yes". BSP_SD_Init() sets the BUS to 4 wire mode which can be seen on the osci creen (if you read or write data of course). If you manipulate the BSP_SD_Init() and set it to SDIO_BUS_WIDE_1B instead of SDIO_BUS_WIDE_4B, data communication is only available on the SDIO_D0 pin.

regarding Q1:

still looking for an answer...

Alex

manurp
Associate II
Apr 2, 2020 3:08 PM UTC

Hi AWilk, have you found an answer to your first question? I was thinking the same thing after watching the video you refered to.

Tesla DeLorean
Guru
Apr 2, 2020 3:48 PM UTC

Drill into the DISKIO layer, and see what functions it is calling, the DMA ones, or not.

Check if you have interrupt handlers in stm32f4xx_it.c, etc.

Look at a .MAP file to see what functions are linked/bound rather than discarded.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
manurp
Associate II
Apr 2, 2020 4:28 PM UTC

Thank you Clive,

Isn't SDIO automatically linked with DMA when configuring it with STM32CubeMX?