Demonstrating Secure Digital Flash Memory Card Functionality Using MPLAB® Code Configurator (MCC) - Step 4: Configure File System (FatFs) and SD/MMC Card Libraries

Last modified by Microchip on 2023/11/10 11:17

Configure File System (FatFs) and SD/MMC Card Libraries


MPLAB® Code Configurator (MCC) is a free graphical programming environment that generates seamless, easy-to-understand C code to insert into your project. Using an intuitive interface, it enables and configures a rich set of peripherals and functions specific to your application. It supports our 8-bit, 16-bit and 32-bit devices, which include our PIC®, AVR® and SAM microcontrollers (MCUs) and dsPIC® Digital Signal Controllers (DSCs). Both the downloadable MPLAB X Integrated Development Environment (IDE) and the cloud-based MPLAB Xpress IDE include MCC.

We’ll be using MCC this time to configure the File System Library (FatFs) and SD/MMC Card Library to complete the exercise. 

Configure File System Library and Add SD/MMC Card Library

From the Project Resources window, select the FatFs library.

Project Resources window

Locate the FatFs tab and click on the Configuration tab. Uncheck the Generate example/demo files box.

Configuration tab

Add the SD/MMC card library by selecting SD Card (SPI) in the Select a physical layer driver: field. Click the + Insert Driver button

Select a physical layer driver: field

Scroll down to the Features Selection and Optimizations section. For the String function optimization pull-down, select 1: Enable without LF-CRLF conversion.

Features Selection and Optimizations section

Scroll further down and find the Select Source of File Timestamps section. Select Use fixed timestamp.

Source of File Timestamps section


Configure SD/MMC Card Library

From the Project Resources window, select the SD Card (SPI) library.

Project Resources window

Locate the SD Card (SPI) tab and make the following changes:

  1. Uncheck the Enable Write Protect (WP) box.
  2. Select Active Low for the Enable Chip Select (CS) Polarity pulldown. 
  3. Select Active Low for the Enable Card Detect (CD) Polarity pulldown.

SD Card (SPI) tab

Note: SPI MCC driver is automatically configured by the SPI Card (SPI) library. 


Generate the code by clicking the Generate button in the Project Resources window.

Generate button in the Project Resources window

The Output window in the lower right window will read “Generation complete” if successful.

Output window