2017-01-15 02:06 PM
Hello
I am reporting a bug generated by cubemx in the file stm32f4xx_hal_sd.c.
Please read the thread:
https://community.st.com/0D50X00009XkfctSAB
,https://community.st.com/0D50X00009XkeRpSAJ
Here is the thing:
1. Pack version: STM32Cube_FW_F4_V1.13.0, Cubemx 4.16.1. The uSD card I tested is 1GB made in japan.
2. The lib for microSD and file is generated by cubemx wizard.
3. I tested the microSD on the chip STM32F405RGT6 . .
4. The problem I confronted is that initialization of sd card always fails, but everything goes through smoothly if I reset the chip(via nrst). Weird? Make the story short. Initialization of SD card fails in the function: SD_PowerON(SD_HandleTypeDef *hsd) with error code SD_COM_CRC_FAILED. Note the function is defined in the file: stm32f4xx_hal_sd.c
5. I moved the HAL_Delay(1) to after clock_enable in the function
SD_PowerON
, everything is working well.I am not sure is this sd card related. Any people has similar problem?
#stm32-stm32f4 #sdio #stm32f411 #bug-stm32cubemx #microsd #stm32-sdio-initialization-errorSolved! Go to Solution.
2017-01-16 04:28 AM
Hi
mao.rongwei
,As said in
https://community.st.com/0D50X00009XkeRpSAJ
, the bug is confirmed and will be fixed in coming driver versions.-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2017-01-16 12:21 AM
SDMMC/SDIO's clock are put out continuously when execute __HAL_SD_SDMMC_ENABLE().
To insert above 1msec delay after __HAL_SD_SDMMC_ENABLE(),it means to send more than 74 initial clock to SDCard.2017-01-16 04:28 AM
Hi
mao.rongwei
,As said in
https://community.st.com/0D50X00009XkeRpSAJ
, the bug is confirmed and will be fixed in coming driver versions.-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2018-03-15 02:07 AM
Hi everyone,
I am using STM32F413 Disc Eval.
I am trying to write- read micro sd ( very old samsung 1gb micro sd card) card using sdmmc driver [without file system] .
Its working fine in debug mode in keil but its not working in normal mode( flash code and press reset).
I tried all the above options .But still problem is not solved.
/* Set Power State to ON */
SDIO_PowerState_ON(hsd->Instance); /* Enable SDIO Clock */ __HAL_SD_ENABLE(hsd); /* Required power up waiting time before starting the SD initialization sequence */ HAL_Delay(2U);/****My code */
HAL_SD_Erase(&hsd, 0X1200, 0X1400);
HAL_SD_WriteBlocks(&hsd, input, 0X1200, 1, SDMMC_DATATIMEOUT); // HAL_Delay(10000); HAL_SD_ReadBlocks(&hsd, output, 0X1200, 1, SDMMC_DATATIMEOUT); //HAL_Delay(1000); printf('\n output is %s \n',output);/*******My Output ****/
SD init Done
CardState is 4
output is
Thanks in advance.Poonam
2018-03-15 06:07 AM
>>Its working fine in debug mode in keil but its not working in normal mode( flash code and press reset).
You'll need to instrument code and output via serial port so you can understand what's happening without the debugger.
Check all clock are enabled properly, and no critical delays, things the debugger may alter.
Don't use arbitrary delays, and review status returned by functions.
2018-03-21 02:09 AM
The problem is solved by adding few lines of code for checking status of SD card.
My code working for SD card read write [512 bytes] in polling mode.
HAL_GPIO_WritePin(LED2_GREEN_GPIO_Port, LED2_GREEN_Pin, GPIO_PIN_RESET);
for (int i =0; i<1;i++) { HAL_GPIO_WritePin(LED2_GREEN_GPIO_Port, LED2_GREEN_Pin, GPIO_PIN_SET); HAL_SD_Erase(&hsd, 0X1200, 0X1400); HAL_GPIO_WritePin(LED2_GREEN_GPIO_Port, LED2_GREEN_Pin, GPIO_PIN_RESET); } while(HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) {} HAL_SD_WriteBlocks(&hsd, input, 0X1200, 1, SDMMC_DATATIMEOUT); while(HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) {} HAL_SD_ReadBlocks(&hsd, output, 0X1200, 1, SDMMC_DATATIMEOUT);2018-09-02 11:57 PM
Thanks for the post. I spent a couple of days looking for an answer to the problem and your post helped me immensely.