2023-04-25 04:03 PM
I am developing project using SD card on custom board but had some difficulties, so I am learning by using the f746g-disco, the example project provided in CubeMX worked (except for Sandisk XC card), then I followed exactly this example (https://community.st.com/s/article/how-to-create-a-file-system-on-a-sd-card-using-stm32bubeide) to generate project using CubeMX, the generated project failed in 'SD_PowerOn'. What could be wrong?
2023-04-27 07:50 AM
Hello @XLin.2 ,
Please share more details about to your post (error message, clock configuration, software/tools version used), this will help us, and community users answered you.
Imen
2023-04-27 08:07 AM
Perhaps also look at
STM32Cube_FW_F7_V1.17.0\Projects\STM32746G-Discovery\Applications\FatFs\FatFs_uSD
2023-04-29 02:04 PM
https://community.st.com/s/article/how-to-create-a-file-system-on-a-sd-card-using-stm32bubeide
and don't forget to follow the tip of.
(Community Member)
3 months ago
Actions for this Feed Item Comment
Made it work with couple of modifications:
1- Moved variables to global
move
"
/* USER CODE BEGIN 1 */
FRESULT res; /* FatFs function common result code */
uint32_t byteswritten, bytesread; /* File write/read counts */
uint8_t wtext[] = "STM32 FATFS works great!"; /* File write buffer */
uint8_t rtext[_MAX_SS];/* File read buffer */
/* USER CODE END 1 */
"
to
"
* USER CODE BEGIN PV */
FRESULT res; /* FatFs function common result code */
uint32_t byteswritten, bytesread; /* File write/read counts */
uint8_t wtext[] = "STM32 FATFS cali666siy great!"; /* File write buffer */
uint8_t rtext[_MAX_SS];/* File read buffer */
/* USER CODE END PV */
"
2- Changed 4B wide operation to 1B operation in "MX_SDMMC1_SD_Init()"
static void MX_SDMMC1_SD_Init(void)
{
/* USER CODE BEGIN SDMMC1_Init 0 */
/* USER CODE END SDMMC1_Init 0 */
/* USER CODE BEGIN SDMMC1_Init 1 */
/* USER CODE END SDMMC1_Init 1 */
hsd1.Instance = SDMMC1;
hsd1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
hsd1.Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE;
hsd1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
hsd1.Init.BusWide = SDMMC_BUS_WIDE_1B; //Start with 1B instead 4B. Later "SD_Widebus_Enable" command makes it 4B
hsd1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
hsd1.Init.ClockDiv = 0;
/* USER CODE BEGIN SDMMC1_Init 2 */
/* USER CODE END SDMMC1_Init 2 */
}
now it works OK. Tested with 4GB and 16GB FAT32 formatted uSD cards
2023-05-01 09:26 AM
Thanks RRibe! It works on 746G-DISCO now. Just curious why 4 lanes didn't work, anyhow my custom board is 1 bit, I will try on it.
2023-05-01 10:39 AM - edited 2023-11-20 07:07 AM
I am still having problems with my custom board, which is Stm32H753, SD in 1 bit mode, Input clock 200Mhz, SDMMC2 interface as SD, with clock divide by (3+1), no transceiver. It always fail in SD_PowerON(). I traced it to SDMMC_CmdAppCommand()
, where it sends 0x37 and expects the same comes back from RESPCMDR registers. There was no timeout or CRC errors, just the RESPCMDR was 0.
I have attached a screen capture. I am not familiar with SD cards, please help.
The pins for SD are PD6(CLK), PD7(CMD), PB14(D0), all are high speed AF, with internal pull ups. I am using CubeMX 6.8 with H7 package 1.11.0.
2023-05-02 04:58 PM
Let me know this can help you >>> https://community.st.com/s/question/0D50X0000AntM27SQE/stm32h7-and-usd-card-on-sdmmc1-using-stm32cubemx-and-hal
2023-05-03 11:39 AM
Still no luck yet. A question I have is about pins: Looking at the schematics of my board, it is in 1 bit SD mode. D1-D3 on the card slot side are left floating, should they be pulled? And for CLK/CMD/D0 are internal pullup (40Koms) enough?
2023-05-03 01:20 PM
first -
2023-08-17 12:53 AM
Have you enabled DMA for fatfs? If so, some comments need to be cancelled in sd_diskio.c.
/* USER CODE BEGIN enableSDDmaCacheMaintenance */
#define ENABLE_SD_DMA_CACHE_MAINTENANCE 1
/* USER CODE END enableSDDmaCacheMaintenance */
/* USER CODE BEGIN enableScratchBuffer */
#define ENABLE_SCRATCH_BUFFER
/* USER CODE END enableScratchBuffer */