2012-08-07 09:55 AM
Hi everyone,
I am trying to send some bytes of data on a sd-card (8GB) using SPI.I started with wiring the sd slot and configuring the spi but I have nothing, not even the clock...I have followed what's explained in the file spi.h and seen other post about spi but I still don't see where I am wrong.I'd really appreciate if you can help me with it ! Thank you. #spi-sd-card-stm32-discovery2012-08-08 10:27 AM
Ok great, I should be good since I just have to write a line every 5 minutes...
I try like that.There's something I didn't understand with your fatfs example : You're writing in a txt file but you don't load it, right ? Where does it go ? I don't see it anywhere.Thank you.2012-08-08 10:45 AM
I wrote the file to the SD card, so the file can be examined when the card is later plugged into a PC. I'm not sure of the merit of loading the file? I read the MESSAGE.TXT to demonstrate reading and computing a file length.
It was done this way so the board could be run head-less (ie without an LCD or serial output), but you could still tell if it accessed the card and used FATFs successfully. I have a serial port connected to my STM32F4-Discovery, many people do not.2012-08-08 03:29 PM
Ok I see, but in your code I didn't see any SDIO initialization nor GPIO. I guess you just didn't put this bit in the fatfs example, right ?
Ok I'll try this tomorrow now ! Thanks a lot for your help !2012-08-08 03:47 PM
The SDIO and GPIO are initialized from diskio.c disk_init()
2012-08-09 04:28 AM
2012-08-09 04:35 AM
2012-08-09 04:56 AM
Ok, I found it in discovery.c and discovery_sdio.c !!! I'll take a look at that !! :)
2012-08-09 05:50 AM
I plugged it and launched it, I can observe the command signal sent by the stm32 to the sd card but when I try to read it from my computer, There is nothing ! I reated the 3 txt files in the card and nothing is modified in them !
2012-08-09 07:53 AM
More investigation showed that res gets FR_DISK_ERR.
res = f_mount(0, &fs32); <<<<<<<<<<<<<<<< Returns FR_OK res = f_open(&fil, ''MESSAGE.TXT'', FA_READ); <<< Returns FR_DISK_ERRI guess it can only come from '&fil' since the file is in the card.Or, could it be because of the card type ?I use a Transcend SDHC card (8GB) class 6.After the simulation, all fil's arguments are equals to 0, even if I put FA_CREAT_NEW.Thanks.2012-08-09 08:45 AM
Or, could it be because of the card type ? I use a Transcend SDHC card (8GB) class 6.
That or how you have the socket wired up. You'll get errors if the SD card initialization fails, suggest you instrument the code and look at the initialization and card reading code. I'm using assorted Micro SDHC cards, and I'm using 33K pull-ups based on what was in my parts draw. It is a bit hackish, I have a custom STM32F2 based board with a built-in socket that I do my primary development on, which has a far more considered design.