Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 3 months ago.
How program SD card on SDIO interface and HAL library for stm32f4xx?
CubeMX generate initcode for SD-card and sdio:
include the mbed library with this snippet
/* SDIO init function */ void MX_SDIO_SD_Init(void) { hsd.Instance = SDIO; hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; hsd.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; hsd.Init.BusWide = SDIO_BUS_WIDE_1B; hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE; hsd.Init.ClockDiv = 0; HAL_SD_Init(&hsd, &SDCardInfo); HAL_SD_WideBusOperation_Config(&hsd, SDIO_BUS_WIDE_4B); }
I try use this functions:
include the mbed library with this snippet
/* Blocking mode: Polling */ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks(SD_HandleTypeDef *hsd, uint32_t *pReadBuffer, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumberOfBlocks); HAL_SD_ErrorTypedef HAL_SD_WriteBlocks(SD_HandleTypeDef *hsd, uint32_t *pWriteBuffer, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumberOfBlocks); HAL_SD_ErrorTypedef HAL_SD_Erase(SD_HandleTypeDef *hsd, uint64_t startaddr, uint64_t endaddr);
but sd card is not visible (SDCardInfo).
1 Answer
8 years, 4 months ago.
Hi, You may visit the following link to get the full video tutorial on SD Card Programming.
https://www.youtube.com/watch?v=kRhF44v2ezM
Sorry, I don't have a solution for you, but it may be useful to examine the example sources in the STM32FCube firmware package. There are examples for the EVAL boards regarding SDIO. See for example STM32Cube_FW_F4_V1.7.0\Projects\STM324xG_EVAL\Applications\FatFs\FatFs_uSD
posted by David Lowe 21 Sep 2015Hi David! I wached this example. Error occure when I try formatting sd card and create file... But now SDCardinfo.capacity and block size contain correct values.
posted by Alexey Melyashinsky 21 Sep 2015