Loading...
 

System Workbench for STM32


NUCLEO-F429ZI - SDIO - FatFS - Stm32CubeMX

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 picture SD Card   Nucleo F429ZI Connection
Board PIN SD Pin
PD2 2 (CMD)
PC8 7 (Dat0)
PC9 8 (Dat1)
PC10 9 (Dat2)
PC11 1 (Dat3)
PC12 5 (CLK)

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 msg15;
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

 

Newest Forum Posts

  1. Problem programming chip by JimELi, 2019-03-25 21:26
  2. CubeMT code, generated for SW4STM32 by market14, 2019-03-25 03:57
  3. Problem verifing and downloading code by strohmas, 2019-03-24 23:16
  4. Nucleo-144 TCP Problems by mklee, 2019-03-22 19:25
  5. CubeMX function pack development by ajcurtis84, 2019-03-22 18:59
  6. STM32CubeMX LWIP not working by leflingue, 2019-03-22 12:22
  7. STM32CubeMX LWIP not working by matsjuhlin, 2019-03-22 09:13
  8. STM32F746-Discovery by stanandrzej, 2019-03-21 12:41
  9. System Workbench takes up to five minutes to load by Servant, 2019-03-21 02:39
  10. How to use multiple ST boards simultaneously by Kevarek, 2019-03-20 19:21

Last-Modified Blogs