AnsweredAssumed Answered

Problem using CubeMX 4.24 + FatFs R012.c + SDMMC1 with nucleo L476RG

Question asked by Elkin Granados on Mar 8, 2018
Latest reply on Mar 20, 2018 by Alexander Wolf

Hi everyone,

 

Since a couples days ago I'm trying to set a project in which I can use a micro SD card using the nucleo board L476RG. I'm using CubeMX 4.24 and the HAL library 1.11 for L4 for making all the settings and I also checked the example that is provided for the L476 eval board. I think that all the settings are right, I compare it with the example and it is almost equal. Some captures from cubeMX:

 

After doing all the configurations I generated the code, So I copied some parts of the example and added to my code. I started with this:

 

 if(retSD == 0)
 {
     if(BSP_SD_Init() != HAL_OK)
      {
         Error_Handler();
      }

      res = f_mkfs(SDPath, FM_ANY, 0, workBuffer, sizeof(workBuffer));

      if (res != FR_OK)
      {
          Error_Handler();
      }
 }

But the function f_mkfs always returned FR_DISK_ERROR. So I check the forum and I find that changing the name of the SD callback functions could help to avoid the error. So I changed from sd_diskio.c:

//void BSP_SD_ReadCpltCallback(void)
void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd)
{
  ReadStatus = 1;
}

//void BSP_SD_WriteCpltCallback(void)
void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd)
{
  WriteStatus = 1;
}

And I comment those functions from bsp_driver_sd.c.

 

After did that, the SD_WRITE function works and the f_mkfs  returned FR_OK, also I can mount the unit but when I tried to open or create a file the function reaches the timeout and return error. I found that the RxCallback is never reached when the f_open function is called.

I'm not sure, but I think that there is an error with the DMA configuration or maybe could be a harware error, here is a picture of the board with the adapter:

Attached to this post is the code for SW4STM32. If there is other way to set the FatFs I'll be glad to receive all the suggestions. If you need any additional info don't hesitate to request. Thank you so much!!

Attachments

Outcomes