2018-06-11 12:56 AM
Dear All,
I’m new to this forum and to stm32 board. I’m trying to connect an SD Card to my board NUCLEO-F429ZI but I’m having some problems with it. I use STM32CUBEMX to create the project using the standard peripherals settings. I put SDIO in SD 4 bit interfacing mode. I do not change anything in clock configuration. I connect the SD Card directly to SDIO PIN without any resistors as in picturehttp://www.openstm32.org/dl422?display
Board PIN SD Pin PD2 2 (CMD) PC8 7 (Dat0) PC9 8 (Dat1) PC10 9 (Dat2) PC11 1 (Dat3) PC12 5 (CLK)3.3V VCC
GND GND
this is the piece of code:
HAL_UART_Transmit(&huart3, “Start\r\n�, strlen(“Start\r\n�), 0xFFFF);
FRESULT res; uint32_t wbytes; uint8_t wtext[] = “text to write logical disk�; FATFS_LinkDriver(&SD_Driver, SDPath); if(f_mount(&SDFatFS, (TCHAR const*)SDPath, 0) == FR_OK) { HAL_UART_Transmit(&huart3, “Mounted\r\n�, strlen(“Mounted\r\n�), 0xFFFF); res = f_open(&SDFile, “STM32.TXT�, FA_CREATE_ALWAYS | FA_WRITE); if (res == FR_OK) { HAL_UART_Transmit(&huart3, “Opened\r\n�, strlen(“Opened\r\n�), 0xFFFF); if(f_write(&SDFile, wtext, sizeof(wtext), (void *)&wbytes) == FR_OK) { HAL_UART_Transmit(&huart3, “Written\r\n�, strlen(“Written\r\n�), 0xFFFF); f_close(&SDFile); HAL_UART_Transmit(&huart3, “Closed\r\n�, strlen(“Closed\r\n�), 0xFFFF); } } else { char msg; sprintf(msg, “Error open: %d\r\n�, res); HAL_UART_Transmit(&huart3, (uint8_t *)msg, strlen(msg), 0xFFFF); } } FATFS_UnLinkDriver(SDPath);The function F_MOUNT return FR_OK but the program stops there. Sometimes the f_open function return Error 3: Device not ready. Any suggestion?
Thank you for your time.M
Solved! Go to Solution.
2018-06-11 10:56 PM
I found the solution disabling the use of DMA Template (USE_DMA_CODE_SD) in FatFS configuration in CubeMX. There are some misconfiguration in DMA code (as Imen suggested document). Thank you all for help.
Nello
2018-06-11 04:00 AM
People seem to have a lot of issues with CubeMX in this regard. I just port the examples in the HAL trees.
You should instrument the DISKIO code and look for errors reported there.
Check if you have dependencies on a Card Detect pin.
Here using the two GPIO below the SDMMC signals for the CD, and WP pins
2018-06-11 06:19 AM
Hello,
You can follow this document
https://community.st.com/0D50X00009bMM7JSAW
which helps you to configure CubeMX + SDIO +DMA + FatFS.
I hope it will help you.
With Regards,
Imen.
2018-06-11 11:23 AM
Are we sure these ideas are bullet-proof? Lot of forum traffic seems to suggest otherwise.
2018-06-11 10:56 PM
I found the solution disabling the use of DMA Template (USE_DMA_CODE_SD) in FatFS configuration in CubeMX. There are some misconfiguration in DMA code (as Imen suggested document). Thank you all for help.
Nello