SD CARD using SPI in STM32 || Cube-IDE || File handling || uart

Поделиться
HTML-код
  • Опубликовано: 5 сен 2024

Комментарии • 315

  • @aricrowe2887
    @aricrowe2887 4 года назад +4

    Great video, thank you so much for your help! As other users have mentioned, if using an stm32f0 discovery board, make sure to set the spi data size to 8 bits. I also ran into a error where I could not build my project with a max sector size of 4096 (too large) so I changed it to 2048 and it worked fine.

    • @sharanrv
      @sharanrv 4 года назад

      Hey! Are you using STM32F051 Board?

  • @jamestroup417
    @jamestroup417 4 года назад +2

    Awesome tutorial. I can confirm that this works on clone chip CS32F103 Bluepill board using 32Gig Transcend SD card . Thank you Controllers Tech for your hard work.

  • @user-mn6us8xl5x
    @user-mn6us8xl5x 4 года назад +1

    Thank you very much for your initiative. The only sensible code that I found after a long time of searching. But in the beginning there was a problem: the program did not always work. In the end, the whole problem was in SPI1. After connecting the microsd module to SPI2, the program always worked. I'm using stm32f4discovery (stm32f407vg microcontroller).

    • @user-mn6us8xl5x
      @user-mn6us8xl5x 4 года назад

      By the way, I connected the sandisk 16gb fat32 memory card and the program worked.

    • @erdinckaya3731
      @erdinckaya3731 2 года назад

      @@user-mn6us8xl5x I'm using the same item.I didnt get it worked. Could you tell me what was the error ? Are you also sure that it's all about SPI1 ?
      Thanks in advance..

  • @golfercab7323
    @golfercab7323 4 года назад +2

    This helped a lot, thank you for the detailed walk-through!!!

  • @divanbessinger6899
    @divanbessinger6899 3 года назад +1

    Thanks for the video! I had to keep the MAXX_SS at 512 for my SDHC 16GB SanDisk to work.

  • @ibrahimkhadraoui7736
    @ibrahimkhadraoui7736 5 лет назад +2

    Thank you very much the best tutorials for stm32 in RUclips

  • @lauchokyip
    @lauchokyip 4 года назад +2

    Great Video! Some boards set SPI to 4 bits ( hspi1.Init.DataSize = SPI_DATASIZE_8=4BIT). I changed it to ( hspi1.Init.DataSize = SPI_DATASIZE_8=8BIT). Btw I am using STM32F0Discovery Kit

    • @saikrishnakaruturi2958
      @saikrishnakaruturi2958 10 месяцев назад

      Hey are you able to read the file on the SD card using the STM32f0 series board?

  • @mukulsharma-no4uf
    @mukulsharma-no4uf Год назад +1

    Hello @ControllersTech I'm using the same MCU and same IDE as in your video, but my code gets stuck at HardFault_Handler(void) when i try to open a file. how to solve it?

  • @theraja011
    @theraja011 5 лет назад +1

    Thanks, Can you pls share any example regarding GSM communication with USART(with CTS/RTS).

  • @ShawnHymel
    @ShawnHymel 4 года назад +5

    Thank you so much for posting this video! I was able to get it working with an SD card formatted with a block size (allocation unit size) of 512 bytes. How do you get it to work with other block sizes (for example, I'm trying to use a block size of 4096 bytes)? Is that possible?

    • @ControllersTech
      @ControllersTech  4 года назад +2

      Change the max sector size to 4096 in the fatfs setup.

    • @ShawnHymel
      @ShawnHymel 4 года назад

      @@ControllersTech Thank you. I can get it to work with cards up to 8 GB, but over that, they don't work. Is there something special I need to do with >8GB cards (other than format them with FAT32 and 4kB block sizes)?

    • @ShawnHymel
      @ShawnHymel 4 года назад +2

      I was able to get it working by upgrading to the newest version of the library: github.com/eziya/STM32_SPI_SDCARD.

  • @davidpelyva311
    @davidpelyva311 5 лет назад +4

    Thanks for the video. I tried to do everything according to your video, but it doesn't work.
    I'm working with the same SD-card module as you, but with an STM32L432KC. The first problem is that I don't have fsize parameter in FIL typedef.
    And the second is that it always says that the card is mounted successfully, even if there is NO CARD in the reader. What is more, I get Disk_error if I try to write or read a file on the card.
    Could you please help me?

    • @lauchokyip
      @lauchokyip 4 года назад +1

      Try writing this
      DSTATUS my_status = SD_disk_initialize(0);
      if(my_status == STA_NOINIT ){
      send_uart ("error in initializing SD CARD...
      ");
      }
      if (my_status == STA_NODISK){
      send_uart ("No medium in the drive...
      ");
      }
      if (my_status == STA_PROTECT){
      send_uart (" Write protected...
      ");
      }
      This will help to know if your disk initialization fails. Remember to #include "fatfs_sd.h"

    • @ucNguyen-wu2xh
      @ucNguyen-wu2xh 4 года назад

      I have Same problem. Did you solve it ?

    • @fifa7150
      @fifa7150 4 года назад

      @@ucNguyen-wu2xh I am using the STM32L4KC too. I used the same files that he used in the video, but I changed the HAL library
      with this #include "stm32l4xx_hal.h" in the fatfs file, and it worked.

    • @marc0711
      @marc0711 3 года назад

      Instead of the 'fsize' parameter you can use the 'f_tell' function.

  • @MrEdwardhartmann
    @MrEdwardhartmann 3 года назад

    Nice video - I am planning a project to take sound files (.wav) from a SD card and output to I2s on a STM32F411 and I have never used Cube to program. This looks like a great starting point - thanks for all the work.

    • @ControllersTech
      @ControllersTech  3 года назад +1

      Better watch the wave player video.
      That's exactly what's done in that.

    • @MrEdwardhartmann
      @MrEdwardhartmann 3 года назад

      @@ControllersTech thanks - I will

  • @encryptedchannel213
    @encryptedchannel213 2 года назад +1

    ERROR!!! in mounting SD CARD... how get I solve this problem

  • @batcircuit4742
    @batcircuit4742 6 месяцев назад

    I am getting "Hard error occurred in the low level disk I/O layer" Error while trying to get the card size, but the card size is displayed 0, what should I do?

  • @user-iy1nl6ke8r
    @user-iy1nl6ke8r Месяц назад +1

    Anyone, please helpme. Why f_puts don't work?

  • @desaoaraujo
    @desaoaraujo Год назад

    Thanks for the video!! Worked here in my STM32L152 Disco board, with minor adjustments. I was able to create files, write and read. However, a few weird outcomes: total and free sizes result with a dot before the number (numbers seem correct); also, the current version of FIL struct in ff.h doesn't seem to have the .fsize field, so I haven't found a way to read the correct amount of bytes yet.
    Thanks again!

  • @MounikaGuntha
    @MounikaGuntha 6 месяцев назад

    Excellent sir,where i can find block diagram for this project??

  • @stefanputureanu9296
    @stefanputureanu9296 4 года назад

    I had made some changes, there are some variables types that are not right. I run this project at 18MBits/s with no errors. I used keil uVision.
    // "sprintf" needs an "unsigned long" input. Note that despite the fact that int and long are represented by the same number of bits, they are still different types.

  • @sureshp632
    @sureshp632 4 года назад +1

    thank you sir can you guide how the usb interfacing

  • @El_Alawy
    @El_Alawy Год назад

    hello, I followed all the steps but every time I find the sd-card empty. I tried to find what is the reason for that by making leds light at every operation of the SD_card function and found that the function enters the first if condition which mean (No SD Card found) and break.

  • @GabiMartin97
    @GabiMartin97 2 года назад

    Working flawlessly. thanks

  • @self-studyelectronicengine7294
    @self-studyelectronicengine7294 3 года назад +1

    Thanks for this Code
    please keep going and make video like this video

  • @kalaiarasi8931
    @kalaiarasi8931 7 месяцев назад

    Hi..The tutorial is really awesome.Asper the instruction i have implmented the code but i am gettingg DISK_Error fom return staement of FRESULT?How to troublehoot the prooblem.kinldy explain

  • @normanwiedemeyer3338
    @normanwiedemeyer3338 2 года назад

    Thank you very much, worked like a charm!

  • @utsavsuha
    @utsavsuha Год назад

    Hello,
    Everything working well. But i need to log 10 bytes of the data after every 5 milli seconds and this should be done for 24 hours,
    The SPI hangs (remains in busy and locked state)after some times and i can only write for few mins of data.
    Please suggest

  • @ubotics27
    @ubotics27 5 лет назад

    Very well explained! May I ask , how can you write data to the next line in the text file ? I have been trying to write Buffer data vertically in the TXT file but they all go horizontal. I will really appreciate your help .thanks

    • @ControllersTech
      @ControllersTech  5 лет назад +4

      Use the '
      ' at the end of the string. That way, next string will be written in the next line

  • @nterminator8347
    @nterminator8347 3 года назад +1

    Hello! Thanks you for the video! My controller is F103C8. How can i get throw away trouble with an error of mounts the SD card while microcontroller initialized? I had my spi speed set to about 2.5MB. I'm was formatted my sd card to fat32 file system, block size 512. p.s. miso mosi connected cross to cross. p.p.s I'm use external +5 volt supply for sd card module. Maybe I'm doing something wrong?

    • @ControllersTech
      @ControllersTech  3 года назад +1

      debug and check the output of fresult.. and read the description

    • @nterminator8347
      @nterminator8347 3 года назад +1

      @@ControllersTech Hi. Tnx for the answer. fresult returns fr_not_ready, when 3rd argument is 1. If I use 0 its sayed its fr ok, but after when try to read or write the code its return fr disk error

    • @nterminator8347
      @nterminator8347 3 года назад

      I'm use 5 volts...

    • @erdinckaya3731
      @erdinckaya3731 2 года назад

      @@nterminator8347 I also need the answer of this question.
      I'm taking the same error and i also get fr_invalid_object error.
      How can i do more debugs without getting into low layer @Controllers Tech

    • @erdinckaya3731
      @erdinckaya3731 2 года назад

      @@ControllersTech waiting for you response below.. Thanks in advance..

  • @fifa7150
    @fifa7150 4 года назад

    Great video! It was very helpful to me I am very thankful :)

  • @alexandrev.3332
    @alexandrev.3332 2 года назад

    I tryed to invert the wires MOSI and MISO and nothing, i tryed to put external 5V to the SD card board and nothing, all the same error

  • @rubens5563
    @rubens5563 5 лет назад

    Thank you for sharing your work. I would like to know if the fatfs library is compatible with Keil

  • @sureshp632
    @sureshp632 5 лет назад

    Thanking you sincerely regarding our tutorial. can you please guide Can TRANSCEIVER MCP 2551 WITH STM32F4

  • @marcinorszulak7780
    @marcinorszulak7780 3 года назад

    Hi, Is there anything else to do, except replacing libraries with old one, to avoid getting FR_NO_FILESYSTEM? Iam using F303RE board

  • @suleyman9847
    @suleyman9847 Год назад

    Thats a very useful video thnk you so much

  • @ganeshgaikwad2158
    @ganeshgaikwad2158 5 лет назад +1

    Thank you sir.. for this amazing tutorial. Can you please guide for this with Compact flash card with stm32f3..

    • @fifa7150
      @fifa7150 4 года назад +1

      It's the same for other STM, I use the stm32l432kc and it works fine. For doing so, you have to change the name to the library according with your microcontroller in the fatfs file. For example: #include "stm32l4xx_hal.h" I included this in my case in yours: #include "stm32f3xx_hal.h" I think

    • @tomashort675
      @tomashort675 4 года назад +1

      @@fifa7150 could you share your code for this type stm please?

  • @alexandrev.3332
    @alexandrev.3332 2 года назад

    The video is very good, i know that the problem is with me, but i can identify the error. I used your whole code download and nothing

  • @netherlabgames7511
    @netherlabgames7511 3 года назад

    Every 512th character in the file is in error. This must be an indication of the block size being in error or something. What do I have to do, format the SD card? It says its block size is 512

  • @aaronrenny7246
    @aaronrenny7246 3 года назад

    Very informative video. Can i use the same code for interfacing in Keil software.? Please help.

  • @alonsorodriguez6042
    @alonsorodriguez6042 4 года назад

    Hello, I have a question. I'm using FreeRtos and Timer 1 as the source, so there is no SysTick_Handler fuction in stm32f1xx_it.c. Where would I put the FatFsCnt check in this situation?

  • @alexandrev.3332
    @alexandrev.3332 2 года назад

    I commented this lines and it is working now, pay attention everybody that is anyone that is starting with this example to comment this if you want to put the sd card in your pc to see the data that was written on the sd card. I used a 16GB San Disk Ultra MICRO SD HC I and now worked. I think that cards with 2GB not work because i tested with 2 of then, maybe i should make the same thing that i did when formatted the sd card. The codes of control tech work really, but if you download the already code you have to follow the comments of the video about change MAX_SS to 4096 and USE_LFN to ENABLED WITH STATIC WORKING buffer on bss . When you format the SD CARD should make with FAT 32 and choose 4096 bytes. And slow the speed of SPI to 2.25MBps and i put external 5V power. Control tech have very good videos. I don´t like when my things not work, sorry about my declaration that i did before. Thank you very much for this video. And i am sending my contribution to this site.
    /*************************REMOVING FILES FROM THE DIRECTORY ****************************/
    /*
    fresult = f_unlink("/file1.txt");
    if (fresult == FR_OK) send_uart("file1.txt removed successfully...
    ");
    fresult = f_unlink("/file2.txt");
    if (fresult == FR_OK) send_uart("file2.txt removed successfully...
    ");
    /* Unmount SDCARD */
    /*
    fresult = f_mount(NULL, "/", 1);
    if (fresult == FR_OK) send_uart ("SD CARD UNMOUNTED successfully...
    ");
    */

  • @alexandrev.3332
    @alexandrev.3332 2 года назад

    I am using a SanDisk 2GB microSD. Could be this problem? I tryed to format inf FAT and FAT32 and used and nothing is write

  • @frasitdar1712
    @frasitdar1712 5 лет назад +1

    From where do i copy the library files fatfs_sd.c and .h files into the folders of project.

    • @ControllersTech
      @ControllersTech  5 лет назад

      Just download the code. They are in the inc and sec folders

  • @AnglasMechatronics
    @AnglasMechatronics 4 года назад

    Great very good information, would you recommend some books from where you are learning all that, please I would appreciate it very much.

    • @ControllersTech
      @ControllersTech  4 года назад

      Don't know man.. I generally use the sensor datasheet itself. And rest is the research..

    • @jotham123
      @jotham123 3 года назад +1

      there's a book called Mastering STM32 - very useful.

  • @purposeoflife47
    @purposeoflife47 3 года назад

    i m using this method and one of my sd card is working fine but other is not working. But both sd cards are working fine in laptop. I dont know what is wrong.

  • @alexandertoro8723
    @alexandertoro8723 5 лет назад

    Excellent tutorial.

  • @sureshp632
    @sureshp632 5 лет назад

    thank you sir once again.

  • @alexandrev.3332
    @alexandrev.3332 2 года назад

    ERROR!!! in mounting SD CARD...
    SD CARD Total Size: 0
    SD CARD Free Space: 0
    File1.txt is opened and it contains the data as shown below
    File2.txt created and data is written
    SD CARD UNMOUNTED successfully...

  • @sarathkumar-tf4lr
    @sarathkumar-tf4lr 4 года назад +1

    @controllerstech am using stm32l476rg micro controller when interfacing with micro sdcard adapter am using your program to control it as per your procedure to settings in cubemx....but i get the "ERROR!!! IN mounting sd card" what mistake maybe occurred in my side...please give the solution

    • @ControllersTech
      @ControllersTech  4 года назад +1

      You are getting error in mount itself. There isn't much i can do here.. It Could be anything..
      Check your connection
      Sd card is in FAT format ?
      Check the SPI speed, it should be around 2Mb/s
      Check the connection again.. there could be a loose wire.

    • @sarathkumar-tf4lr
      @sarathkumar-tf4lr 4 года назад

      @@ControllersTech my SD CARD is in FAT32(default) type.....how can i change into FAT type .....

    • @sarathkumar-tf4lr
      @sarathkumar-tf4lr 4 года назад

      @@ControllersTech when am debugging this code "fresult" return a FR_DISK_ERROR givs....what is the problem may happen...please give the solution....

    • @ControllersTech
      @ControllersTech  4 года назад

      Wait for few hrs. I am updating the code. It might work after that. Check after 4 hrs

    • @ControllersTech
      @ControllersTech  4 года назад

      Code updated... check the description

  • @david-kr1zw
    @david-kr1zw 5 лет назад

    Thank for going to the effort of publishing this. I’ve been wanting to get this working for a while so this video is going to be really useful. So far I’ve only “skim” watched it, and I’ve also looked at your website, but in both cases and for the life of me I can’t see where your fatfs_sd.c and fatfs_sd.h files are coming from. i.e. you say copy them into the project, buy where are you copying them from ? Apologies if it’s obvious, and thanks again.

    • @ControllersTech
      @ControllersTech  5 лет назад

      Download the code. Those files are present in src folder and inc folder

  • @mohdsufian2581
    @mohdsufian2581 4 года назад

    have you tried interfacing sht31 temperature and humidity sensor?
    and cmcu-811 VOC sensor?
    it would be very helpful if you post its tutorial

    • @ControllersTech
      @ControllersTech  4 года назад +1

      I don't have those modules.. will buy them when things will be better...

    • @mohdsufian2581
      @mohdsufian2581 4 года назад

      @@ControllersTech sure.... i am sharing my email adress let's have some conversation there.... may be i can help you buying those modules... or if u are from india i can send that module to ue place
      mail id1: msufian@enggenv.com
      mail id2: mohammadsufian95@gmail.com

    • @mohdsufian2581
      @mohdsufian2581 4 года назад

      @@ControllersTechalso I am having some other ideas for you that can help me also...
      looking forward to ur response, by the way, I am an R&D engineer, in a company near capital city Delhi

  • @Eckmuhl29
    @Eckmuhl29 Год назад

    4:05 where do have those libraries? I dont get it

    • @ControllersTech
      @ControllersTech  Год назад

      Download the code and look in the src and inc folders.

  • @willychen5444
    @willychen5444 3 года назад

    Thanks, it's help me a lot!

  • @saurabhkulkarni356
    @saurabhkulkarni356 3 года назад

    hello sir, please make video on MFRC522 RFID with stm32 f4

  • @user-mn6us8xl5x
    @user-mn6us8xl5x 4 года назад

    Hello! Tell me, please, how can I assign a file name to some buffer?

  • @bahadrguven6268
    @bahadrguven6268 3 года назад

    Does not print the value in the variable.Printing ASCI value.Can I fixed?

  • @BogdyMihy
    @BogdyMihy 4 года назад

    Hello! Thanks for the video, it seemed to me quite clear and concise!
    I have a problem however. After doing the f_open command I get a FR_NOT_READY from the fresult.
    I have followed all the indications in the video. The only thing that I don't understand is the clock. I have an STM32WB and as I am new to this I have no clue how to set it, so I basically just let it do it's thing.
    Do you have any idea why I might get that error?

    • @ControllersTech
      @ControllersTech  4 года назад

      Some connection problem. Make sure the card is formatted with FAT or FAT32
      Also try to reduce the SPI speed and see if it can help

    • @BogdyMihy
      @BogdyMihy 4 года назад

      @@ControllersTech Hey! I've just done it and there is no change. I get the same error. (I have a 16Gb card)
      I want to ask you though, why do you set for your clock the two options "HSE" and "PLLCLK" together? If I do this for my microcontroller I instantly get some 0xfffff8 error or something about "Failed to execute MI command".
      Also when you wrote this: fresult = f_mount(&fs, "/", 1); I saw that here you put 0 and on the website there's 1. What is this for?
      Thanks for answering!

    • @ControllersTech
      @ControllersTech  4 года назад +2

      HSE is for selecting external crystal for clock
      PLL is phase loop clock use in all the ARM processors.
      If u are having problems with the clock, i would advice you to not select the HSE and leave the clock input at HSI and use HCLK as 50 or 60 MHz.
      This video was made long ago, and i have modifies the code after that. That's why you might see some changes.
      Although the process remains same.
      Since it seems like you don't have much knowledge about stm32, i would say first try blinking led and start low.

    • @blahman442
      @blahman442 3 года назад

      I face the same issue. Did you fix it?

  • @electronicswitches6010
    @electronicswitches6010 3 года назад

    I am trying to create the file but file is not able to get created

  • @sumeetgaikwad5702
    @sumeetgaikwad5702 Год назад

    hello sir , i want to interface sd card in spi mode with adi sc 594 mcu , do u have any link for other mcu then stm32

  • @taamallahmedtahe7369
    @taamallahmedtahe7369 2 года назад

    Good morning i have a little project that i have to do but do you think that we can transfer files between two stm32 with spi ( files like .txt) thank youu

  • @danpommerening3490
    @danpommerening3490 3 года назад

    Ok I built this for STM32F411CEU WEACT board. using Chan's FatFs R0.12c
    Everthing works good except the "file.size" reference.
    This has been replaced in ChaN's FatFs R0.12c version with f_size(&fil).

    • @themest4833
      @themest4833 Месяц назад

      help me, I don't find a fsize, where is it?

  • @ControllersTech
    @ControllersTech  4 года назад +6

    I have updated the code on 1st JULY 2020. Read the Description for more info.

    • @emreseyyar5078
      @emreseyyar5078 4 года назад

      where can i download fatfs_sd.c and fatfs_sd.h libary ?

    • @ControllersTech
      @ControllersTech  4 года назад +2

      @@emreseyyar5078 go to the link in the description.. download the code, and you can find the files where i put them in the video

    • @alexandralopes1775
      @alexandralopes1775 4 года назад

      Thank you for the tutorial! Successfully tested on L433 Nucleo board! :) (with some small adaptations of course)

  • @alexandrev.3332
    @alexandrev.3332 2 года назад

    I put external 5V and not worked. I changed of sd card to another one of 16GB and still not working

    • @ControllersTech
      @ControllersTech  2 года назад

      One more comment from you and i will block you.
      I told you, ask in those groups. There is no point in spamming on RUclips

  • @naveenrajy2033
    @naveenrajy2033 4 года назад

    I am trying to access SD card using MikroC for the Board-STM32F446RE...I am facing a problem on Intializing the card ...The statement Fat32_init() does not seems to be working...
    And there is no response from the MISO line .
    Can you please help on this.

    • @ControllersTech
      @ControllersTech  4 года назад

      I don't know. It could be anything... Are u initialising all the peripherals by your own or using cubemx ?
      Also check what error are you getting. You can do this by checking the error status.

  • @baronhelmut2701
    @baronhelmut2701 3 года назад

    The wiring sketch on the thumbnail is wrong.

  • @LuisReyes-zg7mq
    @LuisReyes-zg7mq 4 года назад

    Is there a way to read last 'x' number of bytes from the card?

    • @ControllersTech
      @ControllersTech  4 года назад +1

      Yeah.. You can take a look at the f_lseek.
      Basically just move the pointer to (file size - x), and than read

  • @alexandrev.3332
    @alexandrev.3332 2 года назад

    I am getting this: ERROR!!! in mounting SD CARD...

    ----> I had formatted with FAT and FAT32, i used 2 micro SD cards and anyone works

  • @fernandopiccoli4111
    @fernandopiccoli4111 Год назад

    Hey, I'm saving data on .csv format, and I can't update the file using f_lseek, cause I think it doesn't recognize the filinfo.fsize. Have any tips?

    • @ControllersTech
      @ControllersTech  Год назад

      you can also get the size using the function f_size
      elm-chan.org/fsw/ff/doc/size.html

  • @sureshp632
    @sureshp632 4 года назад

    Sir how to write sensor data to file.txt I am using buf but display zeros only f_sleek(&fil,fil.fsize) but error occur help me please

    • @ControllersTech
      @ControllersTech  4 года назад

      open it as to append data
      f_open(&fil, name, FA_OPEN_APPEND | FA_WRITE);
      and than write
      f_write(&fil, data, strlen (data), &bw);

  • @boobalan789
    @boobalan789 5 лет назад

    Are you Tried SDIO , sd CARD INTERFACE IN stm32f103rctxx Series?

    • @ControllersTech
      @ControllersTech  5 лет назад

      I have stm32f103c8 and it does not support SDIO, so not possible there. But yes, i will soon publish a video about SDIO for those controllers, which supports it

  • @fatimahali2878
    @fatimahali2878 2 года назад

    How to make a file with increment filename?
    Can i make it with same configuration like in your video?

    • @ControllersTech
      @ControllersTech  2 года назад

      File name is a string.
      use something like this
      sprintf(namebuf, "file%d",indx++);
      That's it. Namebuf will have the file names like file1 file2 etc.

  • @aishwaryasr3913
    @aishwaryasr3913 Год назад

    Thank you for the video. I'm facing problem in writing to the SD card. The file gets created but not able to write. The f_write returns FR_INT_ERR. Can you please let me know what could be the issue?
    Note : I am able to read the data written on the card

    • @user-iy1nl6ke8r
      @user-iy1nl6ke8r Месяц назад

      that's same with me, how did you solve that?

  • @jahnvibedia826
    @jahnvibedia826 4 года назад

    I am using F401RE. I am finding problem in disk initialization.
    1. Even when I am not inserting the card there is no difference. It is executing f_mount successfully.
    2. The program does not enter the line ENTER_FF(fs) in ff.c for volume locking.

    • @ControllersTech
      @ControllersTech  4 года назад

      1. Yes that's the bug in the code.
      2. I don't know much about it. I ported the code so that it can work with HAL library.
      What kind of error are u getting exactly

    • @jahnvibedia826
      @jahnvibedia826 4 года назад

      @@ControllersTech I am not able to fetch any values in fs FATFS pointer in ff.c. I am unable to understand why this is happening. I also tried to understand and fetch information about the libraries. But none understood to an extent to solve the problem. Also how did you port the code ? Probably that can work for me too.

    • @ControllersTech
      @ControllersTech  4 года назад

      There are few things
      * Some users have reported that SanDisk cards are not working.
      * Make sure the sd card is formatted in FAT
      * Use the smaller size at first. I have used a 1GB card while making this video

    • @jahnvibedia826
      @jahnvibedia826 4 года назад

      @@ControllersTech I am using F401RE nucleo board. Is it possible that there might be a hardware problem? I read at some places that that might be an issue.

  • @klaus9503
    @klaus9503 3 года назад

    Is there a way to send data with DMA ?

  • @pierrebecam9452
    @pierrebecam9452 3 года назад

    Hello thx for this tuto ! I would like to do the same but with ide arduino ... I didn't find help in the internet, do you think it's possible to interface sd card with stm32f103c8 using spi and arduino ide ?

    • @ControllersTech
      @ControllersTech  3 года назад

      Just use the arduino code. What's the issue ?

  • @xRevollt
    @xRevollt 4 года назад +1

    I am having problems with the "fatfs_sd.h" file : BYTE, DSTATUS, DRESULT, DWORD etc all all marked as "unkown type". Using Keil IDE 5

    • @xRevollt
      @xRevollt 4 года назад

      Also using the Nucleo-STM32F446RE, if that matters

    • @ControllersTech
      @ControllersTech  4 года назад

      I will take a look at it again...

    • @ControllersTech
      @ControllersTech  4 года назад

      Looks like you haven't generated the code properly or something to do with keil..

    • @xRevollt
      @xRevollt 4 года назад

      @@ControllersTech What do you mean by not generating the code properly? I am using CubeMX version 5.5 to generate Keil projects. I added fatfs_sd.c and .h to their folder (Src and Inc respectively), and clicked "Add Existing File to group Application/User". Is there anything else to do to properly link the drivers?

    • @xRevollt
      @xRevollt 4 года назад

      @@ControllersTech Would it be preferable for me to use SDIO, rather than SPI, as it seems my board features a 4bit bus SDIO interface, which I've heard is 4 times as fast as SPI?

  • @dzikrurrohmani7073
    @dzikrurrohmani7073 2 года назад

    what is the difference between "fresult = f_mount(&fs, "", 0);" and "fresult = f_mount(&fs, "/", 1);" ?

    • @ControllersTech
      @ControllersTech  2 года назад +1

      "0" means the card can be mounted later also. We have executed the command and now it can mount anytime.
      "1" means mount the card immediately.
      "/" Is the path of the sd card, where the mount will take place.

    • @dzikrurrohmani7073
      @dzikrurrohmani7073 2 года назад

      Thankyou sir..

    • @dzikrurrohmani7073
      @dzikrurrohmani7073 2 года назад

      @@ControllersTech I wanna ask again, why I can't use it inside HAL_TIM_PeriodElapsedCallback function for interrupt?

  • @dtonn
    @dtonn 2 года назад +1

    Valeu!

  • @paulg.3067
    @paulg.3067 4 года назад

    What write speed (MB/s) to card can I expect using this method?

    • @ControllersTech
      @ControllersTech  4 года назад

      Not much. Try around 2Mb/s and than go higher..

  • @trigonokalanto3217
    @trigonokalanto3217 8 месяцев назад

    hello , first of all thanks for this tutorial. I tried this project with stm32f446re and it works pretty well. But i need to save a value every 10us at specific .txt file. For this reason i open , write and close the .txt file into an tim_irq_handler. It seems that the proccess of saving the data takes longer than expected. Do you have recommended changes in the above code to enhance performance?
    Thank you !

  • @anhtuta2767
    @anhtuta2767 2 года назад

    thank you so much

  • @neilwrightson5660
    @neilwrightson5660 4 года назад

    The above link for the code etc just take you to a blank white page.

  • @vivekpkd
    @vivekpkd 3 года назад

    Can u please share this using standard peripheral library

  • @alexandrev.3332
    @alexandrev.3332 2 года назад

    Your software for me not worked. I make all the things and the total size shows zero and not write or read anything. I did all of the video and not work. I am using 2GB micro sd

  • @radosawpuchalski2251
    @radosawpuchalski2251 4 года назад

    I have some strange problem during compiling. There are an compile error: "#error This file is not needed in current configuration. Remove from the project." in cc932.c.

    • @ControllersTech
      @ControllersTech  4 года назад

      Maybe things have changed with new version of HAL.. i have to check it again..

    • @radosawpuchalski2251
      @radosawpuchalski2251 4 года назад

      @@ControllersTech Thank you. Let me know, if you check, please. I have tried many solutions and I don't have an idea what to do.

    • @ControllersTech
      @ControllersTech  4 года назад

      Which controller do you have

    • @radosawpuchalski2251
      @radosawpuchalski2251 4 года назад

      @@ControllersTech I have checked F746ZG, but I have F410RRB and F103RB (all Nucleo boards) too. Of course I've changed header includes in every file with it.

  • @souradeepdas368
    @souradeepdas368 4 года назад

    Plzzzzzzzzzzzzz help me. I have an tf card module and want to use it with stm32f103c8t6 in arduino (using SPI). But I cant do it. Plzzzz help me.

    • @ControllersTech
      @ControllersTech  4 года назад

      If you are planning on using f103 as an Arduino, I can't help you out. Better look in the STM32duino forum..

  • @ziyaonal4772
    @ziyaonal4772 3 года назад

    Can we use sdhc cards with this project?

  • @bahadrguven6268
    @bahadrguven6268 3 года назад

    I open a text file, type something and close it, I want to open it again and add something else without losing what I wrote first. it is not working.why?

    • @ControllersTech
      @ControllersTech  3 года назад

      You have to use the append attribute..
      Or do this
      Open the file
      Use lseek to point to the end of the file
      Write the data

    • @bahadrguven6268
      @bahadrguven6268 3 года назад

      @@ControllersTech Thanks a lot

    • @bahadrguven6268
      @bahadrguven6268 3 года назад

      @@ControllersTech what is the the append attribute ?I dont know.Can you help me ?

    • @ControllersTech
      @ControllersTech  3 года назад

      FA_APPEND

  • @paulg.3067
    @paulg.3067 3 года назад +1

    In my project (STM32G017...) f_mount did not succeed but simply hang. Upon further debug inspection it hang/loop endlessly inside a HAL_DELAY() function (fatfs_sd.c --> void SELECT(void) --> HAL_Delay(1))... I followed the answer in this thread by overwriting the HAL_Delay function: community.st.com/s/question/0D50X00009XkXJp/hal-delay-stuck-in-infinite-loopnewbie I did not understand whats the cause of the problem but this answer worked for me. Maybe this helps someone else too.

  • @alexandrev.3332
    @alexandrev.3332 2 года назад

    I did in Arduino and the SD CARD kit that i have work very well. I buy one like your video, but your software don´t write or read anything of SD CARD, not work. I tryed to format in PC but nothing happens, always the same bad things.

    • @ControllersTech
      @ControllersTech  2 года назад

      You posted the comment on the website right?
      Just because you can't get it to work, "you think the code is very wrong" ?
      Sort the comments to "newest first" and see how many people got it to work.

    • @alexandrev.3332
      @alexandrev.3332 2 года назад

      @@ControllersTech Yes, i did all the things and not write or read, but with arduino read and write. I format with fat and then i tryed with fat32, anyone works. Why in arduino works very well. I have blue pill stm32f103c8t6 and i have this board to put the card

    • @alexandrev.3332
      @alexandrev.3332 2 года назад

      @@ControllersTech I copy your program and nothing happens, i did a lot of times and nothing happen or 2G micro SD card, only with Arduino, this is my question. Maybe there is something very simple that i don´t know

    • @ControllersTech
      @ControllersTech  2 года назад

      I don't know why it isn't working for you. Try using external 5V supply to the module. Don't use the bluepill's 5V.
      Also some particular types of sd card don't work. I don't remember which one exactly, but read the comments as some people have pointed it out.

    • @alexandrev.3332
      @alexandrev.3332 2 года назад

      @@ControllersTech But why this sd cards works on arduino uno?

  • @goodwill7643
    @goodwill7643 3 года назад

    Thank you

  • @sureshp632
    @sureshp632 4 года назад

    Thanks sir how to write sensor reading data specially adc in txt file

  • @mohammadal-dossari299
    @mohammadal-dossari299 4 года назад

    It seems f_write can not exceed 1023 for "btw" which is the number of bytes to write. If I try to write 1024 byte, I have FR_DISCK_ERR.
    Can you help me, if that is the maximum length I can write Or there is another problem to be solved.
    Thank you

    • @ControllersTech
      @ControllersTech  4 года назад

      Try changing the data type of btw.. i don't remember what's defined in the code.. just increase it like from uint8 to uint16

    • @mohammadal-dossari299
      @mohammadal-dossari299 4 года назад

      @@ControllersTech "btw" is "UINT". I think it accepts 1024 byte

    • @mohammadal-dossari299
      @mohammadal-dossari299 4 года назад +1

      the problem solved. I think it is a bug in the Fatfs_sd.c
      In function "SD_TxDataBlock" there is NO "return TRUE" if the token =0xFD, it will be always "return False"
      my solution is just adding "else" for the "If" statement and return TRUE there.
      Also, eclipse raise a warning there ('resp' may be used uninitialized in this function) which is make sense in case of 0xFD token.

  • @tjwelsh1438
    @tjwelsh1438 5 лет назад

    Adding this driver to my project overflowed my RAM by like 11kB, any idea where all this extra memory allocation is coming from? I've skimmed through fastfs_sd.c and .h and can't see anything obvious.

    • @ControllersTech
      @ControllersTech  5 лет назад

      Can't say really.. which controller are u using btw ?
      Try not using my code. See the video and write yourself. That way you always know what u r doing and the places, where things get messed up.

    • @tjwelsh1438
      @tjwelsh1438 5 лет назад

      @@ControllersTech Good advice, in the end it had nothing to do with your drivers. Thanks for sharing your code!

    • @kubalec1
      @kubalec1 4 года назад

      ​@@tjwelsh1438 could You share the solution?

  • @windsmall9822
    @windsmall9822 3 года назад

    Thanks

  • @alidemir8434
    @alidemir8434 Год назад

    i get invalid error what to do

  • @dzikrurrohmani7073
    @dzikrurrohmani7073 2 года назад

    Can I change timer1 and timer2 variable inside fatfs_sd.c file?

    • @ControllersTech
      @ControllersTech  2 года назад +1

      They are used for timeout.
      How do you want to change them?

    • @dzikrurrohmani7073
      @dzikrurrohmani7073 2 года назад

      I already use ur code and works inside HAL_TIMPediodElapsedCallback, but max interrupt speed that I could generate is about 0.5 sec, I need it to be faster, what should I do?

  • @TViTklg
    @TViTklg 8 месяцев назад

    Hello. I do it as in video it work! Thank you so much! But I not achieve success this project work with PC and mass storage class configure my project. You have video wich see how to work with mass storage devices? I tried on STM32F103C8T6 and STM32F401CCU6...

    • @ControllersTech
      @ControllersTech  8 месяцев назад

      No not for the Sd card yet.

    • @TViTklg
      @TViTklg 8 месяцев назад

      😪@@ControllersTech

    • @TViTklg
      @TViTklg 8 месяцев назад

      😪

  • @technopeak4313
    @technopeak4313 3 года назад

    i cannot write integer number in text file.i am using f_write.Can you help me?ASCI table writing?

    • @ControllersTech
      @ControllersTech  3 года назад

      Does f_write accepts integer number ?

    • @technopeak4313
      @technopeak4313 3 года назад

      @@ControllersTech DHT_GetData();
      /* USER CODE END WHILE */
      fresult = f_open(&fil,"file.txt",FA_OPEN_APPEND|FA_WRITE);
      f_write (&fil,&Temperature,1,&bw);
      fresult= f_close (&fil);
      fresult = f_open(&fil,"file.txt",FA_OPEN_APPEND|FA_WRITE);
      f_write (&fil,&Humidity,1,&bw);
      fresult= f_close (&fil);
      HAL_Delay(3000);

    • @technopeak4313
      @technopeak4313 3 года назад

      @@ControllersTech how can i fixed?ASCI number writing?

    • @ControllersTech
      @ControllersTech  3 года назад

      Are u serious ?
      Temperature is a float value.. f_write accepts a buffer..
      Use sprintf to convert and store those values in the buffer.
      And then send buffer

  • @bdouram
    @bdouram 4 года назад

    Hi! I followed the tutorial and i have to say thank you! But its not working for me. I have a STM32F446 Nucleo and i got the error saying STA_NO_INIT when i call the function SD_disk_initialize (the disk is not initialized). I watch the video billions of times, and the error persists.
    If you could help me, please.

    • @ControllersTech
      @ControllersTech  4 года назад

      Have you formatted the card with FAT ?

    • @sribooshans4451
      @sribooshans4451 4 года назад

      @Bruno Miranda Did you try it again? We are also trying to access a 8 GB SanDisk SD Card using Nucleo - F446RE and the MikroC PRO for ARM IDE. We are not able to initialise the SD card into SPI mode successfully. Please help us if you are able to get it!

    • @ControllersTech
      @ControllersTech  4 года назад

      It depends on what error are you getting. Try the solution posted in the pinned comment..

    • @sribooshans4451
      @sribooshans4451 4 года назад

      @@ControllersTech We are using SPI 8 Bit mode only

  • @deepkumar-hk6wl
    @deepkumar-hk6wl 5 лет назад

    I am generating code for STM32F32373c using STM32cubeIDE ,but how can i add fatfs_sd.c and fatfs_sd.h
    I am unable to find this file. Please help me .....thank you

    • @ControllersTech
      @ControllersTech  5 лет назад

      Download the code. They are in the src and inc folders

  • @jenscrivener8132
    @jenscrivener8132 4 года назад

    Is the link to the code broken or is it just me?