BASIC4MCU | ◎ STM32F | STM32 | How program SD card on SDIO interface and HAL library for stm32f4xx?
페이지 정보
작성자 키트 작성일2017-09-12 16:37 조회2,779회 댓글0건본문
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
<table cellpadding="0" cellspacing="0" border="0" class="codify_table" style="box-sizing: border-box; background: rgb(255, 255, 255); border-radius: 3px; margin: 0px; border: 0px; border-collapse: collapse; padding: 0px;">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16/* 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); }</table>I try use this functions:
include the mbed library with this snippet
<table cellpadding="0" cellspacing="0" border="0" class="codify_table" style="box-sizing: border-box; background: rgb(255, 255, 255); border-radius: 3px; margin: 0px; border: 0px; border-collapse: collapse; padding: 0px;">1
2
3
4/* 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);</table>but sd card is not visible (SDCardInfo).
댓글 0
조회수 2,779등록된 댓글이 없습니다.
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