0

Hi I am working on STM32F103c8t6 MCU.I am trying to run sd card with spi wiht this library https://github.com/eziya/STM32_SPI_SDCARD do every thing like youtube video and my connection is like video https://www.youtube.com/watch?v=spVIZO-jbxE&t=321s. This is a part of my cod:

send_uart("SD program ready....\r\n");
    
DSTATUS my_status = SD_disk_initialize(0);
 if(my_status == STA_NOINIT ){
    send_uart ("error in initializing SD CARD...\n");
 }else send_uart ("SD initializing OK...\n");
 
 if (my_status == STA_NODISK){
    send_uart ("No medium in the drive...\n");
 }
 if (my_status == STA_PROTECT){
    send_uart (" Write protected...\n");
 }
 
 fresult = f_mount(&fs, "0:", 1);
sprintf(buffer,"mounting SD CARD result:%d\n",fresult);
send_uart(buffer);  

/* Create second file with read write access and open it */
fresult = f_open(&fil, "file2.txt", FA_CREATE_ALWAYS | FA_WRITE);
sprintf(buffer,"open SD CARD result:%d\n",fresult);
send_uart(buffer);  

strcpy (buffer, "This is File2.txt, written using ...f_write... and it says Hello from 
Controllerstech\n");
fresult = f_write(&fil, buffer, bufsize(buffer), &bw);
sprintf(buffer,"write SD CARD result:%d\n",fresult);
send_uart(buffer);  
 

This is my response from uart:

SD program ready....
SD initializing OK...
mounting SD CARD result:1
open SD CARD result:1
write SD CARD result:9

return SD initializing OK.. but mounting SD CARD result:1 that means FR_DISK_ERR. What is the problem ? Iam using a SD module that has a 5v to 3v level shifter ic it can cuse problem?

enter image description here

brhans
  • 14,373
  • 3
  • 34
  • 49
OnlyStar
  • 21
  • 3
  • Have you tried different SD cards? Some manufacturers don't implement SPI mode very well in their SD cards. – brhans Jul 11 '20 at 13:22
  • I tried this module and this SD card with arduino it worked very well – OnlyStar Jul 11 '20 at 13:36
  • Have you followed all the instructions [here on eziya76's blog](https://blog.naver.com/eziya76/221188701172) using the STM32CubeMX tool to generate your project and then adding/editing all the relevant driver code? – brhans Jul 11 '20 at 13:46
  • Yes I a mention in description I do every thing like video .when I do not insert SD card f_mount returned FR_NOT_READY .And initializing of SD card returned ok. – OnlyStar Jul 11 '20 at 16:38
  • Compare the steps you've followed from the video with everything written down in the blog. Make sure that nothing is left out. – brhans Jul 11 '20 at 22:10
  • OK I am following line by line exactly the same with blog code – OnlyStar Jul 13 '20 at 06:01

0 Answers0