2020-03-29 01:34 PM
Hi guys, I'm hoping to find a wizard at FatFS who can help me. So my current set up is, stm32f446re microcontroller, with this micro SD card adapter, I have two SD cards at my disposal, a 2GB Sandisk card and a 16GB Samsung SDHC card. Both cards have been formatted to FAT/FAT32. Communication through SPI.
I have followed this tutorial by controllerstech, however the tutorial uses FatFs version R0.11 whereas my version of STM32CubeIde has version R0.12c.
So after adding the file "fatfs_sd.c" to my source folder (as the tutorial requires), and modifying the Chip Select pin to match my project, I added the sample code to test reading/writing a simple text file. However, the first instruction is to mount the drive, modifying the sample code to this:
<< fresult = f_mount(&fs, "", 1); >>
I get the result FR_NO_FILESYSTEM stored in fresult. After debugging, the initialisation works correctly, but when find_volume() function gets called, which in turn calls check_fs() function (loads sector 0), it returns a value of 3, which means its not a valid Boot Sector according to the function. The error results when the function calls ld_word() and checks if it returns the value of 0xAA55. The array fs->win has these values and upun inspecting its elements, the entire array is 0.
Solutions I have tried:
Changing SD card, the Samsung SD card fails to initialise(error of FR_NOT_READY), I suspect because it is a SDHC card but am totally unsure.
Changing the FatFs version to R0.11 (as in the tutorial) by downloading the project used in the tutorial and replacing the middleware folder in my project with the tutorial's one and replacing the user_diskio, ffconf and fatfs files in the same manner.
Reading thr FatFs archives for help on the error messages.
Chaning the file system to exFat
Any help will be much appreciated, TIA
Solved! Go to Solution.
2020-03-31 09:52 AM
Okay so I managed to sort the issue out, I changed the power supply from 3.3V to 5V of the SD card reader and everything is working. Although the SD card reader specifies it can operate with a 3.3V supply it doesn't seem to work.
2020-03-31 09:52 AM
Okay so I managed to sort the issue out, I changed the power supply from 3.3V to 5V of the SD card reader and everything is working. Although the SD card reader specifies it can operate with a 3.3V supply it doesn't seem to work.
2023-07-11 02:20 AM
Hi, @CReze.1
Have your tried to read and write big size (a hundred K or mega bytes) of text files? Any issue?