The code in the official repo from Bill Greyman has now the support for the libmaple based core (stm32duino) integrated in it. So no need to download it from my repo any more.
Official SD-Fat library repository:
UPDATE TO THIS WARNING. SHOULD BE SOLVED IN THE LATEST REPO. If you have problems using pin 7 for CS, make sure you are in sync with Roger's master STM32Duino repo.
I was just testing an SD card with one of the sketches, and noticed that you CAN NOT use pin 7 in the maple mini (the stm32f103 native SS pin for spi1) for CS. I have not looked at how the library manages CS and how that pin is setup in out SPI library, but I guess there is a conflict in the pin mode. So the work around at the moment is to use a different pin for CS.
- Updated 06/04/2015-
- New update on 07/10/2015 - Small code changes to the library and specially to the SPI library, which should go to Roger's master repo soon.
So as I posted before in the forum, I modified the latest SdFat library from Greiman.
I had submitted him changes for a previous version, but had issues. Now all the issues seem to be corrected in my latest version.
It is available here:
It seems to work fine for me for the few examples I have tested.
If you want the best performance for large transfers, can use DMA mode.
DMA would be advantageous for large transfers, but doesn't help at all, and may even have a penalty, if you are just reading a few bytes to a log and things like that. Now if you transfer images or mp3 files from the sdcard, DMA can improve performance greatly, anything involving big blocks at once.
DMA can be enabled or disabled editing SdSpiSTM32F1.cpp, there is one #define line:
/** Use STM32 DMAC if nonzero */
#define USE_STM32F1_DMAC 1
Comment that line or change the 1 for 0, and DMA transfers will not be used.
RECOMMENDATIONS FOR SPEED:
Use DMA mode.
Set a bigger buffer, ideally 4KB
Read speeds without DMA, 4KB buffer:
read speed and latency
Code: Select all
speed,max,min,avg KB/Sec,usec,usec,usec 676.29,8189,5927,6056 676.38,7467,5927,6054 676.38,7468,5927,6054 676.38,7469,5926,6054 676.38,7472,5926,6054
Code: Select all
read speed and latency speed,max,min,avg KB/Sec,usec,usec,usec 1793.65,4362,2154,2282 1794.30,3227,2155,2281 1794.30,3224,2157,2281 1793.65,3225,2155,2282 1793.65,3224,2154,2282
- -Some cards do not work fine with the default speed. Always give the speed parameter to the driver, such as:
-Some sdcard adapters work better than others (LC Soft one seems to work for everyone).
-CS pin. Besides the possible issue with the hardware SS pin (7 in the maple mini) some people had trouble with others. If you have trouble detecting the card, change to a different pin in a different port. Pin 8 works for me. Pins 1 and 2 have worked for other people.
-SDCards. Not all sdcards work fine. The SPI mode is not the normal one SdCards use, they use SDIO, the library-card compatibility may not be perfect. Try a different card.
-Level converters. Sdcards work at 3.3V, STM32F1 works at 3.3V. Level converters are not needed and may affect reliability. Avoid them if possible.
-Voltage regulators. Some cards include a 5 to 3.3V voltage regulator. Normally that's a 1117 regulator with a fairly high dropout voltage. If you power the card with 3.3 you don't need a regulator. If you are having problems avoid the regulator. DO NOT POWER WITH 5V. Neither sdcards or STM32F1 can work at 5V and will most likely get damaged. If you modify a reader to avoid the regulator, be careful to not power it with an Arduino 5V later.
-SdCard speed. Most cards work fine at DIV2 spi speed. If you have trouble, reduce the speed to DIV4 or even lower. At DIV4 there is very little performance impact because the SPI port is still faster than most cards.