0

i am using stm32f103xx to modify sdcard functions but fresult returns FR_NO_FILESYSTEM and f_mount returns FR_DISK_ERR and I have no idea what is the error.

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();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_SPI1_Init();
  MX_FATFS_Init();
  MX_USART1_UART_Init();
  /* USER CODE BEGIN 2 */

  fresult = f_mount(&fs, "/", 1);
    if (fresult != FR_OK) send_uart ("ERROR!!! in mounting SD CARD...\n\n");
    else send_uart("SD CARD mounted successfully...\n\n");

    /* Check free space */
    f_getfree("", &fre_clust, &pfs);

    total = (uint32_t)((pfs->n_fatent - 2) * pfs->csize * 0.5);

    free_space = (uint32_t)(fre_clust * pfs->csize * 0.5);

    /* Open file to write/ create a file if it doesn't exist */
      fresult = f_open(&fil, "file1.txt", FA_OPEN_ALWAYS | FA_READ | FA_WRITE);

    /* Writing text */
    f_puts("This data is from the FILE1.txt. And it was written using ...f_puts... ", &fil);

    /* Close file */
    fresult = f_close(&fil);

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
      HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
      HAL_Delay(50);
  }
  /* USER CODE END 3 */
}

this was my code initially i was using the library from here UPDATE 2 PART (UPDATE 2 part)

Any help is appreciated thank you.

Maip N.
  • 1
  • 2

0 Answers0