There are two additional info 1. Make sure sd card module gets 5V. Try separate power supply if possible 2. When you format SD card in windows10 with FAT32, select 4096bytes for allocation unit size.
@htlee53712 жыл бұрын
I tried this on F401CCU6,I had to change f_lseek(&fil, fil.fsize) => f_lseek(&fil, fil.fptr).At first,no file was generated.Then I saw this commet,I formatted the card to 4096 and connected 5 volts to vcc.Finally,It worked.👍👍👍👍
@danhchucao32466 ай бұрын
Sir, I follow exactly what u did but when I use Usb cable which give 5V to sd MH-SD card module with sd card adapter, however I cant find the text file in the micro sd card although my system file of sd card was FAT32 and allocation size was 4096bytes. I use STM32F103C8T6, windows 10, and ST link v-2. Please help me, I am really losing patient on this
@SiggyPony2 ай бұрын
Thanks again for another good tutorial :) I wasted 6 hours on official tutorials trying to get an SD Card working with SDIO, gave up and came to try your SPI tutorial and it works :) Now I have it working on both my C8T6 and ZET6
@L2.Lagrange8 ай бұрын
Looks very helpful. I'll be following this tutorial later
@jaimecordoba73639 ай бұрын
Nice tutorial, Sir. Thank you very much!
@NizarMohideen9 ай бұрын
You are welcome!
@kajtus940 Жыл бұрын
Thank You Nizar you are the best! Your explanation is very clear and code is working [just change f_lseek function to -> f_lseek(&fil, f_size(&fil)); ], also thanks for SD reformatting info!
@coolchriss7 ай бұрын
Great tutorial! I appreciate your generousity on giving lessons, I hope you make same tutorial using the chip l293 for both DC motor and stepper motor, again thank you so much❤
@JitaoWu7 ай бұрын
Thank you very much for your patient guidance. I have benefited a lot,thank you❤!
@eklimann Жыл бұрын
HELLO FROM POLAND NIZAR THANK YOU FOR WORKING CODE
@carlosbarberis49 Жыл бұрын
Very good tutorial I tried it with the Nucleo STM32F446RE I had to make a few minor changes but got everything working just fine. The only question I have...Where do I find the additional SD card commands like: create directory, delete directory, delete file, rename file and append to file. Are these functions available within this library somewhere???
@firebirdonfire Жыл бұрын
I can't seem to get this to work at all with the Nucleo F446RE Board. Everything looks correct, but I can't get anything to write to the SD card... I'm using SPI2, pins PB13, 14, and 15. My CS Pin is on PB12. Everything programs, just no file on the SD card...
@lc78279 ай бұрын
Code works fine. However, if you use 3.3V SD card module, you may need to add extra capacitor (47uF? or more) between 3.3V and GND. Without it SD seem to draw too much current and project no longer works.
@gabrielcabrerasanchez15422 жыл бұрын
Hi again bro, a question ,In which file is the function f_lseek(&fil, fil.fsize);? , because I can't find it in the files
@NizarMohideen2 жыл бұрын
f_lseek(&fil, fil.fsize); is in a built-in library of CubeIDE. When Click Middleware → Click FATFS, it will kick in
@NizarMohideen2 жыл бұрын
Middlewares/Third_party/FatFs/src/ff.c
@NizarMohideen2 жыл бұрын
/*-----------------------------------------------------------------------*/ /* Seek File R/W Pointer */ /*-----------------------------------------------------------------------*/ FRESULT f_lseek ( FIL* fp, /* Pointer to the file object */ DWORD ofs /* File pointer from top of file */ ) { FRESULT res; DWORD clst, bcs, nsect, ifptr; #if _USE_FASTSEEK DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; #endif res = validate(fp); /* Check validity of the object */ if (res != FR_OK) LEAVE_FF(fp->fs, res); if (fp->err) /* Check error */ LEAVE_FF(fp->fs, (FRESULT)fp->err); #if _USE_FASTSEEK if (fp->cltbl) { /* Fast seek */ if (ofs == CREATE_LINKMAP) { /* Create CLMT */ tbl = fp->cltbl; tlen = *tbl++; ulen = 2; /* Given table size and required table size */ cl = fp->sclust; /* Top of the chain */ if (cl) { do { /* Get a fragment */ tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ do { pcl = cl; ncl++; cl = get_fat(fp->fs, cl); if (cl fs, FR_INT_ERR); if (cl == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); } while (cl == pcl + 1); if (ulen fs->n_fatent); /* Repeat until end of chain */ } *fp->cltbl = ulen; /* Number of items used */ if (ulen fp->fsize) /* Clip offset at the file size */ ofs = fp->fsize; fp->fptr = ofs; /* Set file pointer */ if (ofs) { fp->clust = clmt_clust(fp, ofs - 1); dsc = clust2sect(fp->fs, fp->clust); if (!dsc) ABORT(fp->fs, FR_INT_ERR); dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1); if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) { /* Refill sector cache if needed */ #if !_FS_TINY #if !_FS_READONLY if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ if (disk_write(fp->fs->drv, fp->buf.d8, fp->dsect, 1) != RES_OK) ABORT(fp->fs, FR_DISK_ERR); fp->flag &= ~FA__DIRTY; } #endif if (disk_read(fp->fs->drv, fp->buf.d8, dsc, 1) != RES_OK) /* Load current sector */ ABORT(fp->fs, FR_DISK_ERR); #endif fp->dsect = dsc; } } } } else #endif /* Normal Seek */ { if (ofs > fp->fsize /* In read-only mode, clip offset with the file size */ #if !_FS_READONLY && !(fp->flag & FA_WRITE) #endif ) ofs = fp->fsize; ifptr = fp->fptr; fp->fptr = nsect = 0; if (ofs) { bcs = (DWORD)fp->fs->csize * SS(fp->fs); /* Cluster size (byte) */ if (ifptr > 0 && (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ fp->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ ofs -= fp->fptr; clst = fp->clust; } else { /* When seek to back cluster, */ clst = fp->sclust; /* start from the first cluster */ #if !_FS_READONLY if (clst == 0) { /* If no cluster chain, create a new chain */ clst = create_chain(fp->fs, 0); if (clst == 1) ABORT(fp->fs, FR_INT_ERR); if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); fp->sclust = clst; } #endif fp->clust = clst; } if (clst != 0) { while (ofs > bcs) { /* Cluster following loop */ #if !_FS_READONLY if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ clst = create_chain(fp->fs, clst); /* Force stretch if in write mode */ if (clst == 0) { /* When disk gets full, clip file size */ ofs = bcs; break; } } else #endif clst = get_fat(fp->fs, clst); /* Follow cluster chain if not in write mode */ if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); if (clst = fp->fs->n_fatent) ABORT(fp->fs, FR_INT_ERR); fp->clust = clst; fp->fptr += bcs; ofs -= bcs; } fp->fptr += ofs; if (ofs % SS(fp->fs)) { nsect = clust2sect(fp->fs, clst); /* Current sector */ if (!nsect) ABORT(fp->fs, FR_INT_ERR); nsect += ofs / SS(fp->fs); } } } if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) { /* Fill sector cache if needed */ #if !_FS_TINY #if !_FS_READONLY if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ if (disk_write(fp->fs->drv, fp->buf.d8, fp->dsect, 1) != RES_OK) ABORT(fp->fs, FR_DISK_ERR); fp->flag &= ~FA__DIRTY; } #endif if (disk_read(fp->fs->drv, fp->buf.d8, nsect, 1) != RES_OK) /* Fill sector cache */ ABORT(fp->fs, FR_DISK_ERR); #endif fp->dsect = nsect; } #if !_FS_READONLY if (fp->fptr > fp->fsize) { /* Set file change flag if the file size is extended */ fp->fsize = fp->fptr; fp->flag |= FA__WRITTEN; } #endif } LEAVE_FF(fp->fs, res); }
@gabrielcabrerasanchez15422 жыл бұрын
Thanks bro, If I have other problems, I'll let you know, hoping for some help, haha
@gabrielcabrerasanchez15422 жыл бұрын
Hey bro I saw a new change for the function f_lseek(&fil,fil.size()); if someone has a problem to intance the method fil.size try to use f_size(&fil) so the function f_lseek would be f_lseek(&fil,f_size(&fil));
@enzl3 ай бұрын
Hello, I am using freertos in my project and I am trying to add the data from my sensors to the SD card. When I use fatfs and freertos settings together, it gives the following error. What could be the reason for this? I would be very happy if you could help me. What should I change when using these two settings? make -j12 all arm-none-eabi-gcc -o "abc_x.elf" @"objects.list" -mcpu=cortex-m3 -T"C:\Users\User\STM32CubeIDE\workspace_1.15.0\abc-x\STM32F103C8TX_FLASH.ld" --specs=nosys.specs -Wl,-Map="abc_x.map" -Wl,--gc-sections -static --specs=nano.specs -mfloat-abi=soft -mthumb -u _printf_float -u _scanf_float -Wl,--start-group -lc -lm -Wl,--end-group C:/ST/STM32CubeIDE_1.15.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.0.200.202406191623/tools/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: abc_x.elf section `.text' will not fit in region `FLASH' C:/ST/STM32CubeIDE_1.15.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.0.200.202406191623/tools/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: region `FLASH' overflowed by 20408 bytes collect2.exe: error: ld returned 1 exit status make: *** [makefile:72: abc_x.elf] Error 1 "make -j12 all" terminated with exit code 2. Build might be incomplete. 04:34:04 Build Failed. 3 errors, 0 warnings. (took 467ms)
@NizarMohideen3 ай бұрын
1. Your program takes more memory than mcu memory. Reduce the size or use higher memory stm32. 2. You are using floating point without enabling float
@angelramirezmartinez25982 жыл бұрын
It worked with 8MHZ in all the clocks, with the stm32f103c8t6 and stm32f411e board. What should I have to modify if I want to increase the clock frequency for example to 72 Mhz?
@tienleminh81293 жыл бұрын
11:50, after I built the code, it made an error: "region `RAM' overflowed by 8592 bytes " could you help me please
@NizarMohideen3 жыл бұрын
It seems like you are using STM32F103C6T6. You need to use at least STM32F103C8T6.
@tienleminh81293 жыл бұрын
@@NizarMohideen I repaired it, thanks a lot for your support
@NizarMohideen3 жыл бұрын
Thanks
@jadsieltrrs62992 жыл бұрын
@@tienleminh8129 how did you fix it ?
@tienleminh81292 жыл бұрын
@@jadsieltrrs6299 "It seems like you are using STM32F103C6T6. You need to use at least STM32F103C8T6"
@p.kaikieu47968 ай бұрын
Dear sir, can u make a video that use another SPI product like Matrix led SPI; 7_seg led SPI ? thank u so much for reading my comment
@maltheengstrm3317 Жыл бұрын
kan ikke lige få det til at virke med STM32F103RT6. compiler fint. kan bare ikke med den version af Cubmx / middelware som jeg har adgang til.
@deepak3409Ай бұрын
Sir please make a tutorial on the topic " how to access external memory W25Q128 using stm32f103" microcontroller.
@SouravNaskar-ng7nm3 ай бұрын
how to write a excell or csv using this and update every row
@michaelbertocchi9 ай бұрын
I've seen many of your super interesting videos! Is this application also adaptable to stm32g431kb?
@kaktusjack1033 Жыл бұрын
excellent explanation
@shenghuang46788 ай бұрын
Thanks, my friends. It's helpful. I have a class10 card worked but a class4 card can't work at all. I don't know the reason.
@thanhnguyentien53172 жыл бұрын
Hello I did the same thing you did it doesn't give any error and shows the same debug as you but when I open the SD file, it's not there Please help me fix it!
@NizarMohideen2 жыл бұрын
Hi, 1. Check the card works on a PC and it’s file system is FAT32 2. Make sure SD card reader VCC gets 5V (Supply 5V to Micro-controller via USB before connecting st-link) 3. Try with a different SD card if you have another. 4. Check the wiring connectins
@thanhnguyentien53172 жыл бұрын
@@NizarMohideen Thank you sir, it worked!
@ufukcanaydogan75592 жыл бұрын
@@thanhnguyentien5317 What was your problem?
@RDGamezz2 жыл бұрын
@@thanhnguyentien5317 What was the problem, can you please help me
@MounikaGuntha9 ай бұрын
I am working on stm32F103C8T6 bluepill..i had done samething in the viedo,but it does not store anything in my SD Card. I am giving 5 Volts to the Vcc.I am using 32 GB Micro Sd card,but it does not show anything.what should i do??
@NizarMohideen9 ай бұрын
Please check everything Wishing you al the best
@Mintonperformance Жыл бұрын
update the f_lseek function --- f_lseek(&fil, f_size(&fil));
@kamarmeredow7644 Жыл бұрын
Hi @NizarMohideen, In fatfs_sd.c GET_SECTOR_SIZE command always returns 512. So i cannot understand what is the meaning of setting MAX_SS config to 4096 in CubeMX. Maybe i dont understand something here?
@premapatil54158 ай бұрын
hello sir, this code is working and executes successfully with 0 errors, but the file "write.txt"is not creating into the sd card, can you please give me the solution for this problem sir?
@smallick6532 жыл бұрын
Hi, is it possible to store a firmware in SD card module and make it work for stm32 chip. Instead of using internal flash memory? I mean can we use external SD card as flash memory for stm32 chip?
@hadhemimasghouni76862 жыл бұрын
Could this code be implemented on stm32F76 ? in fact ,i tried to generate it but i got a prblm with the mounting ...
@trungkiennguyen16032 жыл бұрын
Hello, in this tutorial, I saw you to use SPI 1 for communicating between STM32F103 and SD card module. I want to ask you that dose it work well if I use SPI 2? If it is OK, do I have to change any things in SD library?. Thank you so much!
@NizarMohideen2 жыл бұрын
Actually, the library creator "Lee Ji-hoon" used with spi2. It will work The link is below github.com/eziya/STM32_SPI_SDCARD/tree/master/STM32F4_HAL_SPI_SDCARD I suggest if you want SPI2 with STM32F103C8T6, try with SPI1 first. If everything works well, change to SPI2 You need to modify fifth last line in fatfs_sd.h file extern SPI_HandleTypeDef hspi1; Thanks
@komaroviecoclubpodcast40292 жыл бұрын
write function works but read does not any possible solution?
@bharatpatidar96292 жыл бұрын
Is the procedure applicable on stm32f401 nucleo board?
@rafaeldelpino2378 Жыл бұрын
Is this bluepill original or clone? Here with clone noway to work with debugger
@sudharaniinti Жыл бұрын
Will this work for STM32F303RE?
@priyanshusrivastava92882 жыл бұрын
Hello, I want to do continuos adc data logging in sd at 500Hz rate using the same, can you please tell how?
@NizarMohideen2 жыл бұрын
I am not sure whether spi sd card is capable of writing 500 times in one second. You can put the data in a array buffer and then write it to sd card every one second. If there any data loss, you can reduce the data logging rate.
@vidyadharisakala2204 Жыл бұрын
My module is stm32f407zgt6 which has it's own sd card slot
@amarashokraut25427 ай бұрын
I got errors ‘FIL’ has no member named ‘fsize’
@NizarMohideen7 ай бұрын
use f_lseek(&fil, f_size(&fil)); instead. Thanks
@mastermindsouravnaskar73828 ай бұрын
can i use free rtos ? is there ant tutorial on it?
@NizarMohideen8 ай бұрын
kzbin.info/www/bejne/fXWvlnV4q7SHo9E
@anandakrishnannair2 жыл бұрын
Thank you for your help sir!
@NizarMohideen2 жыл бұрын
You are most welcome
@thanhg013 жыл бұрын
Hi Bro ! I have a string , Ex : Helpme = " nguyentienthanh"; I want to save "Helpme" in SD_card Because "Helpme" always changing Can you help me write a function that saves string like above? Thanks you very much !!
@NizarMohideen3 жыл бұрын
Hi Thành Tiến, You can use separate files for each variables. For example Helpme = " nguyentienthanh"; you can use Helpme.txt and then save the variable without f_lseek(&fil, fil.fsize); It will overwrite in the beginning of the file. Another option is to use eeprom as I have shown in video-no-66 and video-no-67 of my KZbin channel. Thanks
@rift33532 жыл бұрын
is it same if i try in STM32F4 discovery?
@NizarMohideen2 жыл бұрын
The library creator named eziya in github used it for STM32F4. github.com/eziya/STM32_SPI_SDCARD/tree/master/STM32F4_HAL_SPI_SDCARD I modified to work with STM32F1. You can use the original codes
@gurumultitask99792 жыл бұрын
can you show me adding SPI and LCD TFT to GRBL?
@NizarMohideen2 жыл бұрын
I am not familiar with GRBL I have some types of lcd or tft with stm32. links kzbin.info/www/bejne/b3eVmIeYaNOSppI kzbin.info/www/bejne/ol6th6Gif66Dl9E kzbin.info/www/bejne/bpncoYmAZ7pqhac
@meetshah42852 жыл бұрын
Hello, I am using STM32L432 board and I want to write and read data from the SD card, similar to this video. All the settings you did in .ioc were done by me too. The file built with 0warnings and 0 errors. The addition of the unint line in include files was done by me for the respective header files too. I am not able to see the text file on the SD card. Can you help me. Thank you for the video. Please help me. Thank you
@meetshah42852 жыл бұрын
Just one more addition. For me, I was getting error for fil.fsize so I used f_size(&fil) for f_sleek(&fil, f_size(&fil));
@blahman4423 жыл бұрын
I get disk not ready error. What could be the reason?
@NizarMohideen3 жыл бұрын
Hi, 1. Check the card works on a PC and it’s file system is FAT32 2. Make sure SD card reader VCC gets 5V (Supply 5V to Micro-controller via USB before connecting st-link) 3. Try with a different SD card if you have another.
@blahman4423 жыл бұрын
@@NizarMohideen I have tried everything earlier as well. It does not work. I used a 16 GB SD card of San disk formatted as FAT32. Gave external 5V supply. Card works perfectly fine when connected to arduino uno.
@NizarMohideen3 жыл бұрын
If you are using STM32F103C8T6,It should work. To check the solder joints in pins PA4,PA5 PA6 PA7 ,5V AND G, you can connect LED's on it and run a simple blink program. If solder joints are good, make sure PA7 - MOSI / PA6- MISO Make sure the library file name spellings fatfs_sd.h / fatfs_sd.c Make sure you followed all the CUBEIDE settings given below Click connectivity → Click SPI1 For Mode select Full Duplex Master Set PA4 to GPIO_Output Click Middleware → Click FATFS Tick User-defined Configuration → Set Defines For USE LFN (Use Long Filename) select Enabled with static working buffer on the BSS For Max SS (Maximum Sector Size) select 4096 After all if it still not works, you can send me the main.c - user_diskio.c - stm32f1xx_it.c (3 files) to my email nizarmohideen@hotmail.com, I can find any errors on it for you Good luck
@さい-j8e3 жыл бұрын
me too, of cause using the EXACT same STM32F103C8T6 and card slot and etc. And I have checked hundreds times of pins and the cubide settings, but it alwals give me a FR_NOT_READY. When I debug into the code, it seems initialize failed, because SD_SendCmd(CMD0, 0) returned 255 instead of 1
@さい-j8e3 жыл бұрын
Oh by the way. I have 4 different micro sd cards, they all returns FR_NOT_READY. Is it possible that the firmware package version has some problem? I'm using FW_F1 V1.8.0, and I don't know why stm32cubeide doesn't let choose version earlier than 1.8.0. of cause i have downloaded some old versions in package manager.
@alexandrev.33322 жыл бұрын
Format with FAT32 and 4096 bytes, only work with this
@NizarMohideen2 жыл бұрын
Thanks for the infomation
@ufukcanaydogan75592 жыл бұрын
Can ı run with Micro SD Card?
@NizarMohideen2 жыл бұрын
Yes. This module is for Micro SD Card
@ufukcanaydogan75592 жыл бұрын
@@NizarMohideen Thank you, ı have another question. ı did everything but ı couldn't get data in my sd card. Where is my data?
@NizarMohideen2 жыл бұрын
When you format SD card in windows10 with FAT32, select 4096bytes for allocation unit size.
@ufukcanaydogan75592 жыл бұрын
@@NizarMohideen I will try it. Thank you
@ufukcanaydogan75592 жыл бұрын
@@NizarMohideen No sir, it wasn't run..:(
@manofmesopotamia7602 Жыл бұрын
maybe , we can use this tutorial to read gcode!
@vidyadharisakala2204 Жыл бұрын
Hi Nizar while i am running this program in sdio i am getting this error can you tell me why it is coming like that [STM32F407ZGTx.cpu] halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x08000900 msp: 0x20020000