Use your forum account to login.


TOP Contributors

  1. MikroElektronika Team (747 codes)
  2. Shawon Shahryiar (262 codes)
  3. Alcides Ramos Zambrano (170 codes)
  4. S P (67 codes)
  5. Dany (66 codes)
  6. MikroBUS.NET Team (35 codes)
  7. NART SCHINACKOW (34 codes)
  8. Armstrong Subero (26 codes)
  9. Roman Toropov (26 codes)
  10. FOURNET Olivier (25 codes)

Most Downloaded

  1. Timer Calculator (95248 times)
  2. FAT32 Library (50044 times)
  3. Network Ethernet Library (44904 times)
  4. USB Device Library (35002 times)
  5. Network WiFi Library (32187 times)
  6. FT800 Library (28031 times)
  7. GSM click (21765 times)
  8. PID Library (21583 times)
  9. microSD click - Example (17769 times)
  10. GSM 2 click (14784 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back




Author: Dany

Last Updated: 2016-02-28

Category: Storage

Downloaded: 9680 times

Followed by: 6 users

Several libraries for Fat16 and Fat32:
- Fat16Dir (findfirst, findnext) (only P18)
- Fat16DirLFN (Fat16Dir for long filenames) (only P18)
- Fat32_,1 Fat32_2; single and multiple Fat32 device(s) for P18, PIC24, dsPIC and PIC32
- IDE for P18, PIC24 and dsPIC.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Fat" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Fat" changes.

Do you want to report abuse regarding "Fat".

  • Information
  • Comments (21)

Library Blog


* Fat16 Directory and Long file names handling (only P18):

- Fat16Dir

- Fat16DirLFN

* Fat32 filesystem implementation (only P18, PIC24 and dsPIC):

- Fat32_1  - only one file in one directory - see short documentation - full documentation

- Fat32_2 - multiple files in multiple directories - see short documentation - full documentation

- Fat32_1_MD: same as Fat32_1, but more than one Fat32 device possible, still only one file in one directory per Fat32 device. Documentation.

- Fat32_2_MD: same as Fat32_2, but more than one Fat32 device possible. Documentation.

Examples:, (only for Fat32_2),,, and

Fat32 Documentation: Fat32 File System Specification, filename: "fatgen103.doc", and Fat32 structure information.

* IDE driver (only P18, PIC24 and dsPIC):

- IDE  - IDE (harddisk) driver -

The zipfiles have the same content as the packages.

Have fun!

2012-01-22: Version 2.0 published:
An extra version of the Fat32 library is added: Fat32_2, which is capable of handling more than one open file simultaneously (the files can be in different directories).
Additionally a "CopyFile" function has been added.

Have fun!

2012-01-28: The Fat32_cf, Fat32_ide,, fat32_2.ide and Ide libraries for PIC24 are added.

2012-06-08: The help section in the package and zip file has been updated.

2012-07-23: Library version 2.100:

Only one version (hardware independant) of Fat32_1 and Fat32_2 exists from now onwards, the separate mmc, cf and IDE versions are gone.
All routines in the libraries also lost their "hardware" (e.g. "mmc_") prefix.

In return the using software must provide the "hardware dependancy" in the form of 2 routines:
function Fat32_Dev_Read_Sector (Sector: DWord; var Buffer: array[512] of byte): boolean;  // returns true when successfull
function Fat32_Dev_Write_Sector(Sector: DWord; var Buffer: array[512] of byte): boolean;  // returns true when successfull

I personally think this approach to construct the library is much better than the previous one (wich was simply a mistake...)

Have fun!

- Deleted an error in "MakeNewFile". (sorry for the possible inconvenience).
- Changed the signature and usage of "Fat32_Delete": the file needs not to be open before deletion. The name of the file to delete is required as function argument now.

2012-08-02: Changes are made to the "Fat32.." libraries:


Added the following routines:

  •     Fat32_Read_File_Sector
  •     Fat32_Replace_File_Sector
  •     Fat32_Write_Sector
  •     Fat32_Get_File_Size_Sectors
  •     Fat32_CopyFile


  • Uses only one SectorBuffer now: avoids writing conflicts in the same directory area. Saves a lot of ram when more than one file is handled.
  • The routine "Fat32_Write_File_Sector" has been renamed into "Fat32_Replace_File_Sector" (more appropriate)
  • The routine "Fat32_Write_Sector" has been added (same as "Fat32_WriteBuffer" but for whole sectors only).


Fat32 and Fat32_2:
Added the routines "Fat32_RmDir_All", "Fat32_Delete_All" and "Fat32_Delete_Files"

2012-08-16: Added extended documentation for the Fat32(_1 and_2) libraries. Also examples were added.

2012-08-18: In the Fat32 and the Fat32_2 libraries: Changed the result of the Fat32_xxxSpace_GB routines to type real (too much rounding down errors otherwise).

2012-08-29: made "Fat32_Read_File_Sector" faster (Fat32_1 and Fat32_2 libraries).

2012-08-30: streamlined the Fat32_Read_sector and Fat32_Write_Sector procedures in the Fat32_1 and Fat32_2 libraries:
Added "Fat32_Seek_Sector" and "Fat32_Read_Sector"

Removed "Fat32_Read_File_Sector" and "Fat32_Write_File_Sector" (replaced by "Fat32_Read_Sector" and "Fat32_Write_Sector")

2012-09-02: Added "Fat32_Append_Sector" to the "Fat32_1" and "Fat32_2" libraries.

- The "Fat32" library has been rename to "Fat32_1". This is done to avoid name clashes with the Fat32 mE library in the IDE's library manager.
- The "ReadBuffer" routine in the Fat32_1 and Fat32_2 libraries is made faster for 512 byte reads on a file sector boundary.

2012-11-12: The microBasic package(s) ha(s)(ve) been added.

Only the .mcl files are available as "library" files: they are copied from the mikroPascal version (the mP and mB .mcl files are compatible - luckely - ).

If you want to see some sources: look into the mP versions.

The example files are still in mP, not in mB. (I do not have an mB licence, so I can not compile them).

Some of the helpfiles are also still referring to mP, but all library "interfaces" are available in the mB language.

2012-12-07: Fat32_2 has been updated, the file is now compiled with the SSA switched on (gave a problem when used with mBasic).

2013-01-26:  Replaced "Delay_ms" and "Delay_us" by routines available in the Delays lib.
"Delay_ms" and "Delay_us" are inline routines and cannot be used in libraries if they are to be used without source (e.g. non Pascal compilers).

2013-02-07: Made the dsPIC packages available.


2013-10-01: Added the "Fat32_Format" routine to the Fat32_1 and Fat32_2 units.

Those units now use the units "SDMMC_Utils" and "BitUtils" (see for the Fat32_Format routine.

The Fat32_Format routine formats the medium from scratch in contrary to "Fat32_QuickFormat".


2013-10-05: Changed the "Examples": deleted a "delay_ms(1000);" in the beginning of their main file to prevent weird problems with the initialisation of SD/MMC cards.



- Added some extra checks to make sure Fat32_Init detects a Fat32 volume (and only that) properly.

- Added the creation of the FAT entries 0,1 and 2 to the Fat32_Format routine (was mistakenly ommitted).

- Adapted the "Calculate Sectors per cluster" code according to the findings of Serkan (thanks!)

2013-10-09: - Removed an error in the "Fat32_Format" routine.


2014-03-13: The mikroBasic files and zip files have been updated. All mB sources are present now (not tested if compilable though).

2014-10-24: Added both in Fat32_1 and Fat32_2 the routine "Fat32_MkDir_ChDir_FP". It changes the current directory to the lowest level in the directory path specified, while in the mean time creating missing directories.


- Made "MakeNewFile" more time efficient (better short file name generation)
- Changed the usage of "StrAppendPre": only used on a non empty string (string lib problem)

05-11-2014: Changed the routine "MakeShortFileName" to be more efficient (code & time) and more according the Microsoft specification.

2014-12-25: Added the Fat32_1_MD library: is the same as Fat32_1 (only one open file per Fat32 device at one time), but now capable of handling more than one Fat32 device (e.g. SDMMC card and USB Stick) simultaneously.

An example of its usage can be found in the examples folder: project
The example is for PIC24, since it shows the usage of SDMMC card and USB stick together. The latter needs the USB host library.

The documentation is not adapted yet, and the Fat32_2_MD library is under construction.

2014-12-27, Version 3.0: - simplified the interface of "Fat32_init" and "Fat32_QuickFormat" in library "Fat32_2"
- Added library "Fat32_2_MD", capable of handling multiple Fat32 devices, with multiple files/directories in each device. The documentation is adapted.

2015-01-26: Replaced the mB files: all mB files are compilable now (which e.g. means that all "with" statements are dealt with). I could however not link and test the libraries (no mB licence).

2015-02-17: Added the mP for PIC32 libraries. Only compiled, not tested.    

2015-03-23: added now in the documentation the circuit diagram how to use more than one SDMMC card toghether with the Fat_x_MD libarries.


2016-02-28: Version 3.1: Added the routine "Fat32_Truncate".


Tool: Libraries for PIC/dsPIC/PIC32


The tool permits to select MCU's that have a certain set of libraries available. This is important when developing libraries in packages that rely on the existance of other libraries.
For mP, mC and mB, PIC, dsPIC and PIC32.

[Learn More]

USB MSD Host Library


Library for making an USB host capable of reading and writing sectors from/to USB memory sticks ("USB drives" or "pen drives").To read/write actual files from/to the USB memory stick you need still e.g. a Fat16 or Fat32 library (see example).

[Learn More]

PS2 Mouse Read


Returns the Delta X (hor), the Delta Y values (vert), the Delta Z (scrolwheel) values and the button status if one of those has changed. Only tested on P18 with 48 MHz MCU clock (will work probably also on 16 and on lower MCU clock speeds).

[Learn More]