SD Card Setup

How this block appears in a Simulink model?


What can be configured?

Configuration Parameter Selectable Option/Value Description
Chip select pin (CS) 0 to 33 Select pin for CS
Clock pin (SCLK) 0 to 33 Select pin for SCLK
Master read (MISO) 0 to 33 Select pin for MISO
Master write (MOSI) 0 to 33 Select pin for MOSI
Format if mount fail True--False If FAT partition cannot be mounted, and this parameter is true, create partition table and format the filesystem.
Base path The block registers given FAT drive in VFS, at specified base path.
Maximum number of files maximum number of files which can be open at the same time
Allocation unit size If ‘format_if_mount_failed’ is set, and mount fails, format the card with given allocation unit size. Must be a power of 2, between sector size and 128 * sector size. For SD cards, sector size is always 512 bytes.

When to use this block?

This block can be used to initialize the SD card connected to ESP32 device before reading and writing files to it.

How does this block work?

ESP-IDF uses the FatFs library to work with FAT filesystems. FatFs resides in the ‘fatfs’ component.


SD Card demo

Previous : Wireless Communication Block (HIL)
Next : SD Card Read Block