cancel
Showing results for 
Search instead for 
Did you mean: 

SDMMC2 + FATFS not working with ETH + LWIP + FMC [STM32F769-DISCO]

Simon477
Associate

Hello Together, 
I have an issue regarding my STM32 Project I tried different things and do not get any glue...

I had an project with FATFS Lib and SDMMC2 in 4bit mode and it was working fine. After trying to merge the IOC - settings into my bigger project (ETH, FMC, LWIP) it is not working.

The IOC settings are the same, only the system clock is different. The SDMMC2 is using PLL48CLK. 

The software stucks in "BSP_SD_WriteBlocks_DMA()" from "stm32f769i_discovery_sd.c" which ends in stm32f7xx_hal_sd.c.

The bug with the configuration at the init was take into account:

 

/**
  * @brief SDMMC2 Initialization Function
  * @PAram None
  * @retval None
  */
static void MX_SDMMC2_SD_Init(void)
{

  /* USER CODE BEGIN SDMMC2_Init 0 */

  /* USER CODE END SDMMC2_Init 0 */

  /* USER CODE BEGIN SDMMC2_Init 1 */

  /* USER CODE END SDMMC2_Init 1 */
  hsd2.Instance = SDMMC2;
  hsd2.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
  hsd2.Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE;
  hsd2.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
  hsd2.Init.BusWide = SDMMC_BUS_WIDE_1B; //atfasi - 4B
  hsd2.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
  hsd2.Init.ClockDiv = 0;
  /* USER CODE BEGIN SDMMC2_Init 2 */

  /* USER CODE END SDMMC2_Init 2 */

}

 

Normally this one was working at the first project:

 

 

    //*** SD CARD ***
    int error = 0;
    uint8_t fileExists = 0;
    char filename[] = "LOG.CSV";

    res = f_mount(&SDFatFS, (TCHAR const*) SDPath, 0);

    if(res != FR_OK)
    {
	Error_Handler();
    }
    else
    {
	res = f_stat(filename, &fno);

	if(res == FR_OK)	//file exists
	{
	    fileExists = 1;
	}
	else if(res == FR_NO_FILE)
	{
	    fileExists = 0;

	    //create log.csv file with header
	    res = f_mkfs((TCHAR const*) SDPath, FM_ANY, 0, rtext, sizeof(rtext));

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

		//Open file for writing (Create)
		res = f_open(&SDFile, "LOG.CSV", FA_CREATE_ALWAYS | FA_WRITE);

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

		//Write to the text file
		//		res = f_write(&SDFile, header, strlen((char*) header), (void*) &byteswritten);
		f_printf(&SDFile, header);
		//		if((byteswritten == 0) || (res != FR_OK))
		//		{
		//		    Error_Handler();
		//		}
		//		else
		//		{

		f_close(&SDFile);
		//		}
	    }
	}
	else	//error reading status
	{
	    fileExists = 2;
	}

    }

    if(f_mount(&SDFatFS, (TCHAR const*) NULL, 0) != FR_OK) //dismount
    {
	Error_Handler();
    }

 

 

Maybe someone has a hint because I don't know how to proceed...
Ty

0 REPLIES 0