STM32F103xx调试SD卡功能遇FR_DISK_ERR与FR_NO_FILESYSTEM错误求助
STM32F103xx SD卡调试故障排查请求
我正在使用STM32F103xx开发板调试SD卡功能,调用f_mount函数时返回FR_DISK_ERR,后续操作的返回值为FR_NO_FILESYSTEM,无法确定错误原因。我使用的是controllerstech网站UPDATE 2部分提供的库,恳请各位提供技术帮助。
以下是我的初始代码:
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 */ }
内容的提问来源于stack exchange,提问作者Maip N.
相关产品推荐
相关产品推荐

