cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMx FatFs & SDMMC ST32F7

mohamad_armoon
Associate III
Posted on September 10, 2016 at 12:37

Hi every body.

i configure STM32CubeMX to write on SD card. im using stm32f7 discovery board. i set SDMMC on ''SD 4bit wide bus''  and enabled FatFS for SD card.

my main function is :

int main(void)

{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

  HAL_Init();

  /* Configure the system clock */

  SystemClock_Config();

  /* Initialize all configured peripherals */

  MX_GPIO_Init();

  MX_SDMMC1_SD_Init();

  MX_FATFS_Init();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */

  /* USER CODE BEGIN WHILE */

   if(f_mount(&SDDISKFatFs, (TCHAR const*)SD_Path, 0) != FR_OK)

  {

      /* FatFs Initialization Error */

      Error_Handler();

  }else

  {

      if(f_open(&MyFile, ''STM32.TXT'', FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)

      {

        Error_Handler();

      }

      else

      {

        res = f_write(&MyFile, wtext, sizeof(wtext), (void *)&byteswritten);

        if((byteswritten == 0) || (res != FR_OK))

        {

            Error_Handler();

        }

      }

   

      f_close(&MyFile);

  }

  while (1)

  {

  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  }

  /* USER CODE END 3 */

}

after debug i found code hangs on f_open(&MyFile, ''STM32.TXT'', FA_CREATE_ALWAYS | FA_WRITE)

is there any thing more to do , to make it work ??

any help or suggestion would be appreciated.

Thanks in advance

MA.
1 REPLY 1
mohamad_armoon
Associate III
Posted on September 10, 2016 at 14:01