I try to use STM32F103RET6 to read a TF card. Report Disk Error
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-06 9:10 PM
I build the whole program by the IDE.
Following is my code. I can read the CID of the card without select the fatfs middleware. The program report FR_DISK_ERR in f_open. The f_mount works fine.
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_DMA_Init();
MX_RTC_Init();
MX_USART1_UART_Init();
MX_ADC1_Init();
MX_SPI1_Init();
MX_SPI2_Init();
MX_USART2_UART_Init();
MX_SDIO_SD_Init();
MX_TIM1_Init();
MX_USB_DEVICE_Init();
MX_FATFS_Init();
/* USER CODE BEGIN 2 */
printf("\r\n ****** FatFs Example ****** \r\n\r\n");
/*##-1- Register the file system object to the FatFs module ##############*/
retSD = f_mount(&SDFatFS, "", 0);
if(retSD){
printf(" mount error : %d \r\n",retSD);
Error_Handler();
}
else
printf(" mount sucess!!! \r\n");
uint8_t a[1024];
printf("HAL_SD_InitCard %d\r\n",HAL_SD_InitCard(&hsd));
retSD = f_open(&SDFile, "C.txt", FA_CREATE_ALWAYS | FA_WRITE);
if(retSD){
printf(" open file error : %d\r\n",retSD);
}
else{
printf(" open file sucess!!! \r\n");
}
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
retSD = f_open(&SDFile, "C.txt", FA_CREATE_ALWAYS | FA_WRITE);
if(retSD){
printf(" open file error : %d\r\n",retSD);
}
else{
printf(" open file sucess!!! \r\n");
}
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
Labels:
- Labels:
-
FatFS
-
SDIO-SDMMC
-
STM32F1 Series
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-08 1:18 PM
Hello
Line 99 causes reinitialization of SD card with default params.. no need to exist
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-11 7:30 AM
Hello @Mcai.1​ and welcome to the STM32 Community,
Do you have still this problem to solve?
If your problem is resolved, please mark the reply as Best answer (click on "Select as Best").
Imen
When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Thanks
Imen
