2016-05-11 01:39 AM
Does anybody know how to solve the
re-
inserting the
SD card ?
I have a project
generated by STM32CubeMX. I have used it for re-inserting the SD cardthis function
: if (CD_CARD == b_cd) { if (CD_NO_CARD == b_cd_last) { /* insert */ res = f_mount(&SDFatFs, (TCHAR const*)SD_Path, 0); if (res == FR_OK) { App_Clear_Error(ERR_SD_INIT); } else { App_Set_Error(ERR_SD_INIT); } } } else { if (CD_CARD == b_cd_last) { /* eject */ res = f_mount(NULL, (TCHAR const*)SD_Path, 0); App_Set_Error(ERR_SD_INIT); } } b_cd_last = b_cd;Card operations as f_open after re-inserting the sd card
do not work.
#stm32cubemx-fatfs-sd-re-insert2016-05-11 03:22 AM
Hi,
Which firmware package are you using ?You can find a full set of running examples and needed functions within the firmware package which is available on the ST web?Regards2016-05-11 04:25 AM
Hi,
I use STM32CubeMX 4.14.0, STM32CubeF7 1.3.1.I found
a very simple examples for FATFS with an expected card inserted.To test
the cardoccurs
only
once after
reset. Petr2016-05-13 05:29 AM
I found some
solution.
I do not know
why there should bea delay
(HAL_Delay(10) ) ?
if (CD_CARD == b_cd)
{ if (CD_NO_CARD == b_cd_last) { /* insert */MX_FATFS_Init();
HAL_Delay(10); /* min 5 ms */ res = f_mount(&SDFatFs, (TCHAR const*)SD_Path, 1); if (res == FR_OK) { App_Clear_Error(ERR_SD_INIT); } else { App_Set_Error(ERR_SD_INIT); } } } else { if (CD_CARD == b_cd_last) { /* eject */FATFS_UnLinkDriver(SD_Path);
HAL_SD_DeInit(&hsd1); res = f_mount(NULL, (TCHAR const*)SD_Path, 1); App_Set_Error(ERR_SD_INIT); } } b_cd_last = b_cd;