Nucleo L476RG: Interface SD card using SDMMC
HI, I have STM32L476RG nucleo board. I have interface a SD card using SDMMC. I have configured SDMMC as 4bit mode with TX, RX in DMA mode. I have configured FATFS. I have given 47K pull up to DO to D3 and CMD line. I am using CUbeMX 5.5.0. The FATFS version is R0.12c.
When I generate the code and compile, I get error of
void HAL_SD_AbortCallback(SD_HandleTypeDef *hsd)
weak void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd)
weak void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd)
as defined twice in BSP_driver_SD.c and stm32l4xx_hal_sd.c
SO I commented in BSP_driver_SD.c and the code complied.
I flashed the code in my nucleo-l476RG board.
the code is as below
MX_GPIO_Init();
MX_DMA_Init();
MX_RTC_Init();
MX_SDMMC1_SD_Init();
MX_USART2_UART_Init();
MX_FATFS_Init();
/* USER CODE BEGIN 2 */
res = BSP_SD_Init();
if(res != FR_OK)
{
Error_Handler();
}
res = f_mount(&SDFatFS, (TCHAR const*)SDPath, 0);
if(res != FR_OK)
{
Error_Handler();
}
if(f_open(&SDFile, "L4.TXT", FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)
{
printf("Failed to open Write file\r\n");
}
else
{
printf("Opened Write file successfully\r\n");
//Write data to text file
res = f_write(&SDFile, wtext, strlen((char *)wtext), (void *)&byteswritten);
if((byteswritten == 0) || (res != FR_OK))
{
printf("Failed to write file!\r\n");
}
but on ruuning the code, I am getting
Failed to open Write file
Please can you help with the configuration and code.
Thanks,
Hitesh
else
{
printf("File written successfully\r\n");
printf("Write Content: %s\r\n", wtext);
}
f_close(&SDFile);
}
but the
