SD card Info for NJ/NX controller

Modified on Mon, 23 Sep, 2024 at 2:58 PM

Reading SD memory card information




The SDCardInfo function block uses a SendCmd command to read:

• The volume name of the SD card

• The creation date (last formatting)

• The total size of the disk in Kilobytes

• The available size in Kilobytes

The _Card1Ready flag turns ON when the SD card is recognized by the NJ

The variable g_InfoSDCard must be declared in the global variables.




The SDCardInfo function block uses the structure declared in the namespace:



Example of information returned by the FB SDCardInfo



Type of SD

  • SD type "normale" de 2Go formatée en FAT16
  • SDHC de 4Go formatée en FAT32


Hard drives, USB sticks, SD cards use clusters. The size depends on the formatting.

• FAT 16: 32768 bytes.

• FAT32: 4096 bytes.


FAT32 has increased the number of clusters per partition from 65535 to 268,435,455 (228-1).
FAT32 therefore allows partitions of larger size (up to 8 terabytes). In reality, the maximum theoretical size of a FAT32 partition is 8 TB, however Microsoft voluntarily limits it to 32 GB on Windows 9x systems in order to favor NTFS.

Since a FAT32 partition can contain many more clusters than a FAT16 partition, it is possible to significantly reduce the size of the clusters and at the same time limit the waste of disk space.


Using CHKDSK ("Allocation units" means clusters and FAT means FAT16):


SD of 2 Go                                                            SDHC of 8 Go

Total size: 1.975.320.576 / (3 x 1024) = 1.83 Go        7.863.280.000 / (3 x 1024)= 7.49 Go


Typical example:

A file of 70211 bytes will occupy 70211 / 32 768 = 2.142 --> 3 clusters which make 3 x 32768 = 98304 bytes (instead of 70211 bytes)


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article