cancel
Showing results for 
Search instead for 
Did you mean: 

How to use HAL_SD_WriteBlocks_DMA

DMagy.1
Associate

I'm working on a project that requires USB_OTG_FS and USB_DEVICE as MSC; I've managed to hook up the SD card to the USB_DEVICE layer and the HAL_SD_ReadBlocks works fine and I can even play back music from the SD Card via the MSC interface. However the HAL_SD_WriteBlocks gives me a buffer underrun error; and the HAL_SD_WriteBlocks_DMA would work, but it corrupts files; I assume that's cuz I would have to wait a little for the transfer to complete:

My question is: how would I go about doing that?

The SDIO is in 4 bit Wide Bus mode and the microcontroller is an STM32F405RG

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @Dávid Magyar​ and welcome to ST Community,

I advise you to consult the examples provided by ST which exist in the Firmware package. You can get inspiration from the existing examples in the following paths:

Firmware\Projects\STM32446E_EVAL\Applications\FatFs\FatFs_uSD

Firmware\Projects\STM324x9I_EVAL\Applications\USB_Device\MSC_Standalone

Regarding the issue of file corruption, you should certainly wait until the transfer is complete.

I hope this helps!

Best Regards,

Walid

View solution in original post

1 REPLY 1

Hello @Dávid Magyar​ and welcome to ST Community,

I advise you to consult the examples provided by ST which exist in the Firmware package. You can get inspiration from the existing examples in the following paths:

Firmware\Projects\STM32446E_EVAL\Applications\FatFs\FatFs_uSD

Firmware\Projects\STM324x9I_EVAL\Applications\USB_Device\MSC_Standalone

Regarding the issue of file corruption, you should certainly wait until the transfer is complete.

I hope this helps!

Best Regards,

Walid