From Swordfish Wiki

SwordfishUser: SDFileSystemVersion

Version 4.1.4

This is an updated version of the SDFileSystem library module supplied with the compiler. It is now at Version 4.1.4. The module now supports multiple simultaneous files, upto a maximum of 127. The option #option SD_MAX_FILES is used to set the maximum number of files required and should be set as low as possible to reduce RAM use. Note also that the option #option SD_SUPPORT_MULTIPLE_FILES must be set to True for the module to support multiple files. It is set to False by default to maintain backwards compatibility. When set to true, many of the commands in the library require an extra parameter, pFileNumber, passing as the first parameter to indicate which file is being opened, written to, closed etc. In addition, commands such as MkDir and Dir can be used even when files are open, so long as multiple file support is active.

Version 4.1.4 also adds the following commands:

Also new in Version 4.1.4 is the option to use the second MSSP port for PICs that have this facility - use #option SD_MSSP = 2.

See the full version history below for more details.

Version 4.1.4 follows the release of Version 3.1.1. The main additions in Version 3 were support for SDHC high capacity SD cards, as well as support for the FAT32 format. These two combined allowed the use of much higher capacity cards than previously. New commands were also added, namely FATType, SerialNumber, ReadNBytes, Format, DestroyFormat (use with care), FileCount and DirCount. In addition, a new option, #option SD_REINIT_SPI, was added.

Note that the Init command for initialising the card has been changed slightly since Version 3.1.1 and this will necesitate a change to existing user code. The command now returns a byte, not a boolean. The return variable gives more information in case of a failure (see err codes in comments above command in module for details). Note also that when using the hardware MSSP SPI option using #option SD_SPI = MSSP, the SPI bus speed is no longer passed to the Init command as a parameter, but is set using an option, e.g. #option SD_SPI_SPEED = spiOscDiv4. As for all options, this must be placed before the Include "SDFileSystem.bas" statement in the user code.

Steven Wright


Licenses for integration of SD/MMC cards into products may be required from Microsoft, IBM, the SD Card Association (for SD Cards) and the Multimedia Association (for MMC Cards).

Microsoft has been granted patents covering the File Allocation Table (FAT) file system. These patents pertain to the integration of long file names with legacy DOS file names in the same data structure. This library does not support long file names, but there may be issues if the Format or QuickFormat command are used.

It is up to the user of this module to ascertain for themselves if licenses are required from any or all of these or other organizations for the integration of the media or this software into their products. In the event licenses are required from any of these or other organization, it is up to the user of this software to acquire, at their own cost, such licenses directly from the license holders.

Version History

A full list of additions and fixes since Version 1 is given below.


It is suggested that this library is placed in the UserLibrary directory.

Download SDFileSystem Version 4.1.4 »

Download SDFileSystem Version 3.1.1 »

It should also be noted that the revisions are still at the BETA stage. If any problems are found, please raise them via the forum.

Sample Code

Help File

Download SDFileSystem Help File (PDF) »


I would be grateful if you were to post a reply on the Swordfish forum (feedback) if you try the latest version of the module so that I can get a feel for its uptake.

Retrieved from
Page last modified on November 23, 2014, at 08:01 PM