carmsd-cardstm32f4fatfs

Detecting removed SD-Card - C - ARM -


how it is possible to detect the removed SD-Card, and after that how it is possible to detect the inserting and do the re-mounting? I am working at STM32-F401 in C and with fatfs. Detecting incorrect mounting or removed card is relatively easy:

fresult1 = f_mount(&myFATAFS, SDPath, 1)
while(FR_OK != fresult1){
     /*Watch out for sd-card and if you find one try to mount*/
     ...
}

And now?


Solution

  • You can't do it from this level. SD interface has line CD - CardDetect. You should connect it to GPIO and test it in the timer interrupt (EXTI interrupts are not good for that as debouncing is needed)